Question
How can I get a simple table
userType = employee
userType = employer
SELECT (CASE WHEN (userID IS NOT NULL) THEN 'employer' ELSE 'employee' END) AS 'userType' FROM tblEmployer WHERE userID = 401
IF EXSISTS (SELECT userID FROM tblEmployer WHERE userID = 401)
IF ((SELECT COUNT(*) FROM tblEmployer WHERE userID = 401) > 0) ELSE ...
Assignment type not recognized. (near "IF" at position 0)
If you want to return exactly one row, then use aggregation or a subquery in the select
clause:
select (case when exists (select 1
from tblEmployer e
where e.userId = 401
)
then 'employer' else 'employee'
end) as userType
Alternatively:
select (case when count(*) > 0 then 'employer' else 'employee' end) as userType
from tblEmployer e
where e.userId = 401;