Query:
SELECT id, username,
(SELECT username
FROM users
WHERE email = '{$email}'
AND activate = 0 ) AS inactive
FROM users
WHERE email = '{$email}'
AND password = '{$password}'
AND activate = 1
The field email is UNIQUE so there is no duplication in emails.
I want to output the username and the id if the combination email,password,activate=1 exists OR output username as inactive if the combination email,activate=0 exists.
update: this is working
SELECT id,
(SELECT username
FROM users
WHERE email = '{$email}'
AND activate = 0
) AS inactive,
(SELECT username
FROM users
WHERE email = '{$email}'
AND activate = 1
AND password = '{$password}'
) AS active
FROM users
WHERE email = '{$email}'
Try the following
The case statement is present for selecting between multiple options of a column or expression