SELECT COUNT(*) FROM (
SELECT 1 FROM ...
UNION SELECT 1 FROM ...
UNION SELECT 1 FROM ...
) as tmp_table
Despite the result set including multiple rows, COUNT(*)
will always return 1... why?
UNION SELECT
automatically groups your results, meaning that you will not see duplicate rows. What you need is UNION ALL SELECT...
, then your results will not be grouped and you will see duplicate rows.
Duplicate rows meaning, because you always select 1, so it groups by 1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With