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

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -