php - correct mysql syntax for a column not equaling either of two values -
i have table 'cars' column colour. i'm trying build query show cars have 4 doors, exclude cars have 'red' or 'black' recorded in colour column.
select * 'cars' 'cars.doors = 4' , 'cars.colour != red or black'
this doesn't seem work, i'm not sure if because i've got wrong whether there's else in code messing up. ok way?
thanks
you're enclosing conditions in single quotes invalid. should enclose strings in quotes. not red or black part can use not in()
select * `cars` cars.doors = 4 , cars.colour not in('red', 'black')
alternatively can long way, note use of and
not or
because or
wouldn't appropriate want.
and cars.colour != 'red' , cars.colour != 'black'
Comments
Post a Comment