Kemik Posted August 26, 2007 Share Posted August 26, 2007 Hello, I have two queries which searches for any fixtures your clan (team) is in and then returns some information about the fixtures. Is there any way of combining these results and ordering them by date? $query = "SELECT lc.*, cb.name as clan, cb.clan_id, ladder.name as ladder, ladder.ladder_id FROM ladder_challenges lc LEFT JOIN clans cb ON lc.clan_id_b = cb.clan_id LEFT JOIN ladder_config ladder ON lc.ladder_id = ladder.ladder_id WHERE lc.clan_id_a = $myclanid AND lc.accepted = 0"; $query = "SELECT lc.*, ca.name as clan, ca.clan_id, ladder.name as ladder, ladder.ladder_id FROM ladder_challenges lc LEFT JOIN clans ca ON lc.clan_id_a = ca.clan_id LEFT JOIN ladder_config ladder ON lc.ladder_id = ladder.ladder_id WHERE lc.clan_id_b = $myclanid AND lc.accepted = 0"; Thanks all. Quote Link to comment https://forums.phpfreaks.com/topic/66784-combining-query-results/ Share on other sites More sharing options...
corillo181 Posted August 26, 2007 Share Posted August 26, 2007 why dont you do both query together? "SELECT table1.name,table2.name FROM table1,table2 WHERE table1.id=table2.id order by table1.date DESC" Quote Link to comment https://forums.phpfreaks.com/topic/66784-combining-query-results/#findComment-334655 Share on other sites More sharing options...
Barand Posted August 26, 2007 Share Posted August 26, 2007 try a UNION <?php $query = "SELECT lc.*, cb.name as clan, cb.clan_id, ladder.name as ladder, ladder.ladder_id FROM ladder_challenges lc LEFT JOIN clans cb ON lc.clan_id_b = cb.clan_id LEFT JOIN ladder_config ladder ON lc.ladder_id = ladder.ladder_id WHERE lc.clan_id_a = $myclanid AND lc.accepted = 0 UNION SELECT lc.*, ca.name as clan, ca.clan_id, ladder.name as ladder, ladder.ladder_id FROM ladder_challenges lc LEFT JOIN clans ca ON lc.clan_id_a = ca.clan_id LEFT JOIN ladder_config ladder ON lc.ladder_id = ladder.ladder_id WHERE lc.clan_id_b = $myclanid AND lc.accepted = 0 ORDER BY date"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/66784-combining-query-results/#findComment-334666 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.