Reputation: 86845
I want to compare the count between two tables. Or more to say, output if the count from table1 is greater than from table2:
SELECT c1 > c2 FROM
(SELECT count(*) from table1) as c1,
(SELECT count(*) from table2) as c2
(real world selects are much more complex, but same structure)
Result: Unknown column 'c1' in 'field list'
How can I actually evaluate the counts?
Upvotes: 0
Views: 26
Reputation: 1270473
Name the columns:
SELECT c1.cnt > c2.cnt
FROM (SELECT count(*) as cnt from table1) c1 CROSS JOIN
(SELECT count(*) as cnt from table2) c2
Upvotes: 2