I have a below query that returns a result. How can query the result which if there is result, return True, and if there is no result, return FALSE??
SELECT a.id
FROM table1 AS a
INNER JOIN table2 AS c
ON (a.id=c.user_id AND a.id=4 AND c.complete_date is NULL AND c.st_number= 8)
CodePudding user response:
You could use EXISTS
here:
SELECT EXISTS (
SELECT a.id
FROM table1 AS a
INNER JOIN table2 AS c ON a.id = c.user_id
WHERE a.id = 4 AND c.complete_date IS NULL AND c.st_number = 8
);
CodePudding user response:
Try this,
Please don't merge inner join and where condition
SELECT a.id FROM table1 AS a
INNER JOIN table2 AS c ON a.id=c.user_id
where a.id=4 AND c.complete_date is NULL AND c.st_number= 8