7
I have two tables and I must return the total of the table with more data, I am doing so:
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 table familiar
is higher returns 0 and when does not return 1. But as return the value of COUNT
? 'Cause when I put my last name (familiar
or personal
) 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
From the following error:
Unknown column 'familiar' in 'field list'
You could put the code that are in trouble, maybe it helps in the answer.
– novic