MySQL Forums
Forum List  »  Stored Procedures

Re: Using UNION for multi query
Posted by: Peter Brawley
Date: October 11, 2020 09:49AM

> using group by to get the result of each department,

The query does not Group By dept_no.

> aviod duplicate employee numbers

Using Group By emp_no to avoid dupe emp_no values does suppress duplicate emp_no values, but ignores info associated with those suppressed emp_no values, so it's unsound.

In general, to call an sproc to run a union query with the params you indicated, you'd write something like...

drop procedure if exists qproc;
create procedure qproc( pdeptid, presult )
select ...
select ...;

inserting sproc param names where you want the params referenced; you'd call the sproc with literal values or with user variables as you showed.

I don't understand this query requirement yet, I'd need more detail to help more with that.

Options: ReplyQuote

Written By
October 10, 2020 07:44AM
October 10, 2020 10:04AM
October 10, 2020 10:52PM
Re: Using UNION for multi query
October 11, 2020 09:49AM

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.