MySQL Forums
Forum List  »  MySQL Workbench

How to get results from multple queries into one table in MySQL stored procedure
Posted by: Marcus Dardy
Date: May 10, 2018 11:38AM

I have the queries below in one stored procedure and want to put the results of those queries into one tmp table. How do I do that?

Here is some of my MySQL Select queries. These queries are originally pretty long so I scaled them down considerably:

CREATE DEFINER=`server`@`%` PROCEDURE `GetMonthlyRate`()
BEGIN

SELECT HA.ActualWeight, HA.ServiceDate
FROM Hauler HA
Left Join CoreContentType CCT ON OH.CoreContentTypeID =
CCT.CoreContentTypeID
WHERE HA.RecordDisabled = 0 AND
CCT.CoreContentTypeCategoryID = 1;




SELECT OH.ActualWeight, OH.IsRecycleContaminated,
OH.RecycleContaminationPercent, OH.RecycleRebatePercent,
OH.CoreContentTypeID, OH.ServiceDate
FROM OperationsHaul OH
Left Join CoreContentType CCT ON OH.CoreContentTypeID =
CCT.CoreContentTypeID
WHERE OH.RecordDisabled = 0 AND
CCT.CoreContentTypeCategoryID = 1;



SELECT OP.ActualWeight, OP.IsRecycleContaminated,
OH.RecycleContaminationPercent,
FROM Operations OP
Left Join CoreContentType CCT ON OH.CoreContentTypeID =
CCT.CoreContentTypeID
WHERE OP.RecordDisabled = 1 AND
CCT.CoreContentTypeCategoryID = 1;

END

Would this be a CREATE TABLE/INSERT??

Options: ReplyQuote


Subject
Views
Written By
Posted
How to get results from multple queries into one table in MySQL stored procedure
199
May 10, 2018 11:38AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.