tags:

views:

26

answers:

1

Hello,

Anybody can help me with this mysql query:

delete from generic__campaings_included where dealer_id not in ('2,3,4') and campaing_id = '1'

When i execute this query i didnt get normal result. Exceot 2 (dealer_id) all rows deleted.

How can i use "not in" with "and" operator?

PS. Sorry for my english)

+3  A: 

Should it not be this without single quotes?

delete from generic__campaings_included where dealer_id not in (2,3,4) and campaing_id = 1

or this if the columns are string

delete from generic__campaings_included where dealer_id not in ('2','3','4') and campaing_id = '1'

You deleted rows where dealer_id <> '2,3,4' (that is, a string literal rather than one of 2, 3, or 4)

gbn
Right! Thanks a lot!
Nadir