Reputation: 495
Is it possible to compare the result of a query to a string in MySQL? Something like :
select case when 'Captain' = (select role from roleassociation ra
inner join users urs
on ra.userentityid = urs.invuserid
where invuserid = 007)
then 'true' else 'false' end as result;
The above query is incorrect, but is it possible to implement? Thanks in advance.
Upvotes: 1
Views: 79
Reputation: 522646
I would probably just put the CASE
expression in the subquery:
SELECT
CASE WHEN role = 'Captain' THEN 'true' ELSE 'result' END AS result
FROM roleassociation ra
INNER JOIN users urs
ON ra.userentityid = urs.invuserid
WHERE
invuserid = 007;
Assuming you expect the result to be only a single record, you will still have just a single result with this approach.
Upvotes: 1