MySQL Forums
Forum List  »  Newbie

Re: Combine 2 Select Distinct Queries
Posted by: Peter Brawley
Date: March 26, 2017 11:58AM

> from route r , temp_combo t

Without a Where clause, this Comma Join is a Cross Join, ie it will return every logically possible combination of route and temp_combo rows. Surely not what you mean!? You need ...

... from route r JOIN temp_combo t ON r.somecolumn = t.someothercolumn ...

> How can i get them to display side by side?

Is this what you mean?

select a.rt_num, a.tdate, b.pudate
from ( 
  select distinct r.rt_num, date_format(t.pudate,'%y-%m-%d') as tdate
  from route r 
  join temp_combo t on ... -- JOIN COLUMN ARGS REQUIRED
  ) as a
left join (
  select distinct route, date_format(pudate,'%y-%m-%d') as pudate
  from temp_combo
) as b on b.route = a.rt_num ;

Options: ReplyQuote


Subject
Written By
Posted
Re: Combine 2 Select Distinct Queries
March 26, 2017 11:58AM


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.