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 Link to comment https://forums.phpfreaks.com/topic/82830-solved-can-you-do-multiple-tables/ 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 Link to comment https://forums.phpfreaks.com/topic/82830-solved-can-you-do-multiple-tables/#findComment-421227 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? Link to comment https://forums.phpfreaks.com/topic/82830-solved-can-you-do-multiple-tables/#findComment-421228 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. Link to comment https://forums.phpfreaks.com/topic/82830-solved-can-you-do-multiple-tables/#findComment-421231 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 Link to comment https://forums.phpfreaks.com/topic/82830-solved-can-you-do-multiple-tables/#findComment-421289 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.