TFG Posted April 17, 2008 Share Posted April 17, 2008 i have two tables called category and details in my mysql database the category table contains a column called id and has the following rows with the following values 1 2 3 4 5 6 7 8 9 10 and the details table contains a column called categoy and has the following rows with the following values 2 2 2 4 4 8 8 8 8 9 9 10 10 10 and now i am trying to use php to list all the values that are in category tables except the values that are in details table as a result i want the output to be like this 1 3 6 5 7 please give me some idea on this Link to comment https://forums.phpfreaks.com/topic/101510-help-me-with-not-equal-to/ Share on other sites More sharing options...
mrdamien Posted April 17, 2008 Share Posted April 17, 2008 To do this in php, put both tables into an array. <? $id; // The id array. eg: array(1,2,3,4,5,6,7...) $category; // The category array eg: array(2,2,2,4,4,8,8...) foreach($id as $n){ if(!in_array($id, $category)){ echo $n; } } ?> To do this in SQL, SELECT category.id FROM category WHERE category.id NOT IN (SELECT details.category FROM details) Link to comment https://forums.phpfreaks.com/topic/101510-help-me-with-not-equal-to/#findComment-519255 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.