Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.