Exclude a certain row from an MYSQL query


You can exclude a certain row from sql query using '<>' or '!=' clause.

For example,  if you want to exclude the row in the result with user_id => 1 from the table 'poll', following query will give you the desired result.

SELECT *  FROM `poll` WHERE  user_id <> 1

If the data type of id is String you must use 
SELECT *  FROM `poll ` WHERE  user_id <> '1'

Note: In MySQL, you can also use != rather than <> but <> is ANSI and more portable.

Comments

Popular Posts