I've got a simple query which functions correctly, but there are few conditions that need to be checked. This is being done using AND operator, I want to know how can we determine the actual value when an OR condition failed.
Scenario: We've got 3 columns is_blocked, is_verified,is_active Let's say Row 1 has
is_blocked=0
is_verified=0
is_active=0
The message thrown has to be different when each of the condition fails.
if (is_blocked==1) msg=your account has been blocked.
if (is_active==0) msg=your account is no longer active.
if (is_verified==0) msg=you need to verify your account.
Query 1 :
"
SELECT *
from users
WHERE is_blocked = 0
AND is_verified = 1
AND is_active = 0
AND emailid = 'emailid'
"
The above query will return the value as FALSE for the above example. Is there a way for me to figure out with a single query, as to which condition in the query has failed, and what the actual value is. So the expected output will be is_verified=1
I've tried using if condition in PHP something like this.
if (is_blocked=0)
SELECT * from users users WHERE is_verified=1 AND is_active=1
and so on... I am not sure if this is a good practice.