Sid Sid - 3 months ago 14
MySQL Question

How to exclude particular row id from query results?

I have a table of Member, in that I have three rows which has

member_id
s as
admins
,
admin
and
manager
. Now, I want to select all members from the table excluding these three
member_id
's.

For this, I tried the following query:

SELECT * FROM `Member`
WHERE Member.member_id NOT IN (
SELECT member_id
FROM Member
WHERE Member.member_id = 'manager'
AND Member.member_id = 'admins'
AND Member.member_id = 'admin'
)


But still I can see those three rows selected in the result.

How can I do this?

Answer

You need to write query like below :

SELECT * FROM `Member` WHERE Member.member_id NOT IN ('admins' , 'admin','manager');
Comments