I have two tables and should I return the table total with more data, I'm doing this:
SELECT CASE WHEN ((select count(*) as 'familiar' from tb.familiar)) >
((select count(*) as 'personal' from tb.personal))
THEN 0 ELSE 1 END AS total
That way it works, when the familiar
table is greater it returns 0 and when it does not return 1. But how do I return the value of COUNT
? Because when I put the nicknames ( familiar
or personal
) of the count gives syntax error, for example:
SELECT CASE WHEN ((select count(*) as 'familiar' from tb.familiar)) >
((select count(*) as 'personal' from tb.personal))
THEN familiar ELSE personal END AS total
Give the following error:
Unknown column 'familiar' in 'field list'