TheNone
TheNone

Reputation: 5802

Filtering data in Mysql

I know WHERE, LIKE, IN filters in database. But how can I filter with "except" ? I want to select all data except a specificdata. Thanks in advance

Upvotes: 0

Views: 150

Answers (5)

Dennis Haarbrink
Dennis Haarbrink

Reputation: 3760

Three approaches:

WHERE column <> 'something' 
WHERE column NOT LIKE 'something' 
WHERE column not in('something')

Upvotes: 2

Pirozek
Pirozek

Reputation: 1270

Note that you can use another query for NOT IN like this:

SELECT id FROM customers WHERE id NOT IN (SELECT id FROM bad_customers)

Upvotes: 1

Mark Baker
Mark Baker

Reputation: 212412

WHERE NOT LIKE

WHERE NOT IN

Upvotes: 0

Randy
Randy

Reputation: 16677

you can use NOT IN

Upvotes: 1

ahmetunal
ahmetunal

Reputation: 3960

with NOT IN, usage is like IN

SELECT * FROM USERS WHERE ID NOT IN (1,2,3,4,5)

Upvotes: 5

Related Questions