MySQL Forums
Forum List  »  Newbie

Re: select latest records by date and location
Posted by: Rick James
Date: July 11, 2015 12:23PM

This section:
http://mysql.rjweb.org/doc.php/groupwise_max#using_variables
with
FROM Canada
replaced by
FROM ( <subquery with your three tables> ) AS Canada

Yikes! Your SELECT is a CROSS JOIN -- don't you need some way to tie the rows together? That may be the whole problem??

Instead of `from logs, asset, location`, use this syntax:
FROM logs
JOIN asset ON asset.... = logs....
JOIN location ON location.... = logs....

If you had 1K rows in each table, your SELECT would have delivered 1 billion rows (1K*1K*1K)!

Options: ReplyQuote




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.