Select all rows except one in MySQL

select * from table where some_id != 4

You have a few options:

SELECT * FROM table WHERE id != 4;

SELECT * FROM table WHERE NOT id = 4;

SELECT * FROM table WHERE id <> 4;

Also, considering perhaps sometime in the future you may want to add/remove id's to this list, perhaps another table listing id's which you don't want selectable would be a good idea.

In which case you would have:

SELECT * FROM table
WHERE id NOT IN (SELECT id FROM exempt_items_table);

select * from <table name> where <column - name> != <value>;

Tags:

Mysql