A
A
Alexey Chertok2017-10-09 17:10:14
PHP
Alexey Chertok, 2017-10-09 17:10:14

How to exclude one value from SQL when displaying information?

Good afternoon. Can you please tell me how to exclude one value when displaying information from a SQL table?
For example, I get everything without specifying WHERE:
SELECT * FROM `table_1`
Now the news is displayed with all statuses `enabled` (y,n,m,x).
And I need to display absolutely everything write down, but not display exactly those where, for example, `enabled` = 'x'.
How can I do that ?
Is there an exception method? NOT IN?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
V
Vladislav Nagorny, 2017-10-09
@BarnyBroken

SELECT * FROM table_1 WHERE enabled NOT IN (1,2,3,4)
SELECT * FROM table_1 WHERE enabled != 'x'

D
Denis Holub, 2017-10-09
@denman1985

Yes and just != not equal to not in
`enabled` not in ('x', 'y')
SELECT * FROM `table_1` WHERE `enabled` != 'x'

A
Alexander, 2017-10-09
@zkelo

SELECT * FROM `table` WHERE `enabled` != 'x';

V
Vladimir, 2017-10-09
@djQuery

In addition: you may need a mySQL FIND_IN_SET statement, don't forget that.

N
nozzy, 2017-10-09
@nozzy

According to the ANSI SQL standard, you should use <> instead of !=

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question