Reputation: 291
I am creating a service where a user may only log in 5 times maximum before requiring a new account, how may I verify the count (assuming it is stored in a tinyint
column named tries
efficiently without requiring fetching of any columns?
In pseudocode:
SELECT FROM table WHERE userid=$uid AND tries <= 5
But it appears I need to select something regardless of if I need to return something or not. Is there a way to compare if tries <= 5 without selecting? I wish to rely on mysql_num_rows to check if their account is still valid or not if possible instead of comparing the number in PHP.
Upvotes: 0
Views: 435
Reputation: 25564
SELECT COUNT(*) AS answer FROM ...
will return minimal info where 0 can be false, >0 true
Upvotes: 0