Jump to content

[SOLVED] DELETE statement does not affect any table rows


vandana

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.