Zepo. Posted July 25, 2008 Share Posted July 25, 2008 If i want to loop a table but ignore the ones with the same id in anouther table how would i do that in one query? This is urgent so please post suggestions. Link to comment https://forums.phpfreaks.com/topic/116536-solved-loop/ Share on other sites More sharing options...
Barand Posted July 25, 2008 Share Posted July 25, 2008 Use a LEFT JOIN and only print those where values from right table are null Link to comment https://forums.phpfreaks.com/topic/116536-solved-loop/#findComment-599252 Share on other sites More sharing options...
Zepo. Posted July 25, 2008 Author Share Posted July 25, 2008 Use a LEFT JOIN and only print those where values from right table are null Can you give me an example of this please. Link to comment https://forums.phpfreaks.com/topic/116536-solved-loop/#findComment-599625 Share on other sites More sharing options...
Barand Posted July 25, 2008 Share Posted July 25, 2008 see http://www.phpfreaks.com/tutorial/data-joins-unions/page4 Link to comment https://forums.phpfreaks.com/topic/116536-solved-loop/#findComment-599670 Share on other sites More sharing options...
Zepo. Posted July 25, 2008 Author Share Posted July 25, 2008 Wow i got completely lost. Can you please write an example that follows this SELECT * FROM `mybb_offers` WHERE `cat` ='".$cat."' AND `MID` = 'no' ORDER BY `".$orderby."` ".$order." LIMIT $page,10 But where it doesn't pull if ID exists in table offerscompleted in the ID column . Link to comment https://forums.phpfreaks.com/topic/116536-solved-loop/#findComment-599767 Share on other sites More sharing options...
Barand Posted July 25, 2008 Share Posted July 25, 2008 $sql = "SELECT a.* FROM `mybb_offers` a LEFT JOIN offerscompleted c ON a.ID = c.ID WHERE a.`cat` = '$cat' AND `MID` = 'no' AND c.ID IS NULL ORDER BY a.`$orderby` $order LIMIT $page,10"; Link to comment https://forums.phpfreaks.com/topic/116536-solved-loop/#findComment-599774 Share on other sites More sharing options...
Zepo. Posted July 25, 2008 Author Share Posted July 25, 2008 $sql = "SELECT a.* FROM `mybb_offers` a LEFT JOIN offerscompleted c ON a.ID = c.ID WHERE a.`cat` = '$cat' AND `MID` = 'no' AND c.ID IS NULL ORDER BY a.`$orderby` $order LIMIT $page,10"; Thank you so much sir. Link to comment https://forums.phpfreaks.com/topic/116536-solved-loop/#findComment-599792 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.