Dave
Dave

Reputation: 9147

How do I list multiple items in MySQL?

What is the proper syntax for the below code:

SELECT * FROM this WHERE x = 'y' AND id != '10, 11, 143'

The part I am not sure about is listing multiple IDs.

Upvotes: 0

Views: 116

Answers (1)

E.J. Brennan
E.J. Brennan

Reputation: 46839

if id is numeric, you can use

SELECT * FROM this WHERE x = 'y' AND id not in (10,11,143)

or

SELECT * FROM this WHERE x = 'y' AND id not in ('10','11','143')

for strings.

Upvotes: 1

Related Questions