Petty_Crim Posted November 1, 2007 Share Posted November 1, 2007 I'm stuck on this sql query that gets a list of users that can be made into moderators. I got a database with a table called category_moderators, which has two fields category_id and user_id. I'm making a drop down list of available users that can be made into moderators, but I only want to display users who are currently not a moderator for that particular category. This is my query I'm using atm: $get_moderators=mysql_query("SELECT users.user_id, users.user_name FROM users, category_moderators WHERE (category_moderators.category_id='$chosen_category_id' AND users.user_id!=category_moderators.user_id)") Before this query is run the user picks the category they want to add the moderator to as such if they pick say category 1 then the query should exclude listing users that are moderators in category 1. Link to comment https://forums.phpfreaks.com/topic/75610-solved-stuck-on-sql-query/ Share on other sites More sharing options...
rajivgonsalves Posted November 1, 2007 Share Posted November 1, 2007 try the <> instead of the != Link to comment https://forums.phpfreaks.com/topic/75610-solved-stuck-on-sql-query/#findComment-382574 Share on other sites More sharing options...
Petty_Crim Posted November 1, 2007 Author Share Posted November 1, 2007 try the <> instead of the != Nope still doesn't work. Link to comment https://forums.phpfreaks.com/topic/75610-solved-stuck-on-sql-query/#findComment-382581 Share on other sites More sharing options...
bache Posted November 1, 2007 Share Posted November 1, 2007 SELECT u.user_id, u.user_name FROM users u WHERE not exists (select 1 from category_moderators cm where cm.category_id = $chosen_category_id and u.user_id = cm.user_id Link to comment https://forums.phpfreaks.com/topic/75610-solved-stuck-on-sql-query/#findComment-382591 Share on other sites More sharing options...
Petty_Crim Posted November 1, 2007 Author Share Posted November 1, 2007 SELECT u.user_id, u.user_name FROM users u WHERE not exists (select 1 from category_moderators cm where cm.category_id = $chosen_category_id and u.user_id = cm.user_id Thx that seemed to do the trick. Link to comment https://forums.phpfreaks.com/topic/75610-solved-stuck-on-sql-query/#findComment-382602 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.