SirChick Posted December 22, 2007 Share Posted December 22, 2007 Can you do multiple tables in one query ? I have 3 tables which all have a time stamp and the user's ID and was hoping to get all rows from all 3 tables and sort them in ASC order by the time stamp... just curious how you collect multiple tables...? Ive only ever done multiple fields in a query. Hope you can enlighten me Quote Link to comment Share on other sites More sharing options...
benjaminbeazy Posted December 22, 2007 Share Posted December 22, 2007 use a join http://dev.mysql.com/doc/refman/5.0/en/join.html Quote Link to comment Share on other sites More sharing options...
SirChick Posted December 22, 2007 Author Share Posted December 22, 2007 So i would do : SELECT * FROM t1 LEFT JOIN (t2, t3) ON (t2.time=t1.time = t3.time GROUP BY time ASC ) Something like that? Quote Link to comment Share on other sites More sharing options...
benjaminbeazy Posted December 22, 2007 Share Posted December 22, 2007 somethng similar to that, i've only used join a couple times. i think it is more like ON (t2.time=t1.time AND t1.time = t3.time GROUP BY time ASC ) but i could be totally wrong about that. Quote Link to comment Share on other sites More sharing options...
Barand Posted December 22, 2007 Share Posted December 22, 2007 Sounds more like a UNION is required SELECT id, timestamp FROM t1 UNION SELECT id, timestamp FROM t2 UNION SELECT id, timestamp FROM t3 ORDER BY timestamp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.