Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

write select query for the below requirement

This is my users table:

http://ezinfotec.com/Capture.PNG

I need to select all rows those are not contain 2 in except column. How to write a query for this using php & Mysql.

The result i expect for this query is only return last row only.

Thank you.

like image 587
Parthasarathi Avatar asked Feb 14 '26 05:02

Parthasarathi


1 Answers

Don't store comma separated values in your table, it's very bad practice, nevertheless you can use FIND_IN_SET

SELECT
  *
FROM 
  users
WHERE 
  NOT FIND_IN_SET('2', except)
like image 194
Ende Neu Avatar answered Feb 15 '26 19:02

Ende Neu