jeff5656 Posted August 12, 2010 Share Posted August 12, 2010 When I run this query to exclude records where id = $userarray['id'], $q = "SELECT * FROM users WHERE inst_id = '". $userarray['inst_id'] ."' AND id != '". $userarray['id'] ."' "; it actually ONLY returns records with $userarray['id'] as opposed to excluding them. Isn't the way to exclude them to use != ? Link to comment https://forums.phpfreaks.com/topic/210561-excluding-records-in-a-query/ Share on other sites More sharing options...
linus72982 Posted August 12, 2010 Share Posted August 12, 2010 I believe you have to use "NOT" instead of != within an sql query. Link to comment https://forums.phpfreaks.com/topic/210561-excluding-records-in-a-query/#findComment-1098565 Share on other sites More sharing options...
linus72982 Posted August 12, 2010 Share Posted August 12, 2010 Actually, I just read up on it and learned that != is viable in a query, so, nvm. Link to comment https://forums.phpfreaks.com/topic/210561-excluding-records-in-a-query/#findComment-1098598 Share on other sites More sharing options...
marcus Posted August 12, 2010 Share Posted August 12, 2010 $sql = "SELECT * FROM `users` WHERE `inst_id`='".$userarray['inst_id']."' AND `id`<> '".$userarray['id']."'"; Link to comment https://forums.phpfreaks.com/topic/210561-excluding-records-in-a-query/#findComment-1098601 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.