I would do this:
select count(*) records
from users
where id = 1
Then I would check the value of records in my application.
Question
I need to know which is the best way to check for a row:
Without column; only just a number:
SELECT 1 FROM users WHERE users.id = 1 LIMIT 1
With column and database( users.id )
SELECT users.id FROM users WHERE users.id = 1 LIMIT 1
With column and without database
SELECT id FROM users WHERE id = 1 LIMIT 1
With all fields( obviously inefficient ):
SELECT * FROM users WHERE users.id = 1 LIMIT 1
And It is recommended to use the sentence "limit" when the sentence "exists" is used?
Example with limit:
SELECT products.* FROM products
WHERE EXISTS(
SELECT 1 FROM users WHERE users.id = products.user LIMIT 1
)
Example without limit:
SELECT products.* FROM products
WHERE EXISTS(
SELECT 1 FROM users WHERE users.id = products.user
)
Thanks!
No correct solution
OTHER TIPS
I would do this:
select count(*) records
from users
where id = 1
Then I would check the value of records in my application.