Muhammed Ashik Muhammed Ashik - 11 months ago 47
MySQL Question

Multiple AND/OR logic messed up

I need to get my data when

and status= In use or Pending or Deleted.
But I am getting extra data not sure why.

I am getting extra data from


MySQL query is:

SELECT * FROM `registered_bicycle`
WHERE (`userID`='4')
AND (`status`='In Use')
OR (`status`='Pending')
OR (`status`='Deleted')

enter image description here


Try this instead:

WHERE `userID` = '4'
AND `status` IN('In Use','Pending','Deleted')

Your and/or logic got mixed up because of lacking proper parentheses. Also you can use IN instead of multiple OR clauses.

Btw, IN is just the short form of OR