Skip to content
Advertisement

When using an OR operator, will the query return left condition over the right?

I want to return a single row but want one query to qualify the two conditions.

For example

SELECT * FROM user WHERE admin < 10 OR admin > 100 LIMIT 1

When I query this, will this return the first row it finds that has an admin value less than 10? If not, how would I achieve this?

Advertisement

Answer

You can do this using order by. I would suggest:

SELECT *
FROM user
WHERE admin < 10 OR admin > 100
ORDER BY admin
LIMIT 1
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement