MySQL Forums
Forum List  »  Stored Procedures

Re: Joining On Procedure Results
Posted by: Peter Brawley
Date: July 18, 2009 08:37AM

> Is it possible to join a table on the results from a stored procedure within a single query?

No.

And in the query ...
select id, values 
from mytable
where maxTarget = (
  select max(maxTarget) 
  from mytable where id = _id 
  group by id
);
Group By is useless in the subquery, and it would be more efficient to move the subquery to the FROM clause, eg ...
select id, values 
from mytable m
join (
  select max(maxTarget) as maxt 
  from mytable where id = _id 
) t on m.maxtarget = t.maxt;

PB
http://www.artfulsoftware.com

Options: ReplyQuote


Subject
Views
Written By
Posted
22304
July 17, 2009 06:50AM
Re: Joining On Procedure Results
8232
July 18, 2009 08:37AM
6032
July 24, 2009 06:16AM
5658
July 24, 2009 06:28AM
5050
July 27, 2009 07:34AM


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.