vandana Posted July 27, 2008 Share Posted July 27, 2008 Hi, I have a table with a group_id and a groupmember_id When I apply this query: DELETE FROM jos_group_groupmembers WHERE groupmember_id != 1 AND group_id != 74 it doesn't work. Why not. The table looks like group_id groupmember_id 74 1 74 4 74 5 I want to delete the second and third row. Why does the above query not work? Please help . Kind regards, Vandana Quote Link to comment https://forums.phpfreaks.com/topic/116835-solved-delete-statement-does-not-affect-any-table-rows/ Share on other sites More sharing options...
paul2463 Posted July 27, 2008 Share Posted July 27, 2008 because you are using the AND word......... you are asking it to delete any rows that ARE NOT groupmember 1 AND ARE NOT group_id 74... for this to be true they both have to BE NOT , as all rows are group_id 74 then all will fail because both items are not met if you change it DELETE FROM jos_group_groupmembers WHERE groupmember_id != 1 AND group_id = 74 this will delete rows 2 and three because it is now being asked to delete rows which ARE NOT groupmember 1 BUT ARE equal to group_id 74 or you could change it DELETE FROM jos_group_groupmembers WHERE groupmember_id != 1 OR group_id != 74 this will do the same, it will delete rows 2 and 3 but it will also delete every row where the group_id IS NOT 74 HTH Quote Link to comment https://forums.phpfreaks.com/topic/116835-solved-delete-statement-does-not-affect-any-table-rows/#findComment-600771 Share on other sites More sharing options...
vandana Posted July 27, 2008 Author Share Posted July 27, 2008 Hi Paul, Thank you very much... I did not see that...stupid.. Anyway thank you, Vandana Quote Link to comment https://forums.phpfreaks.com/topic/116835-solved-delete-statement-does-not-affect-any-table-rows/#findComment-600777 Share on other sites More sharing options...
paul2463 Posted July 27, 2008 Share Posted July 27, 2008 please click "solved" if my answer worked for you Quote Link to comment https://forums.phpfreaks.com/topic/116835-solved-delete-statement-does-not-affect-any-table-rows/#findComment-600786 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.