I had a mysql query :
Select count(*) as cnt from page06 where dl = 1 and TYPE = 'mempage' union
Select count(*) as cnt from page06 where err = 1 and TYPE = 'mempage' union
Select count(*) as cnt from page06 where dl = 1 and err=1 and TYPE = 'mempage'
In most cases dl
and err
columns are 0 so two last select will return 0
. I found out this query returns only one that is not what i expected. I found this solution:
Select count(*) as cnt,'s' as p from page06 where dl = 1 and TYPE = 'mempage' union
Select count(*),'d' as p from page06 where err = 1 and TYPE = 'mempage' union
Select count(*),'f' as p from page06 where dl = 1 and err=1 and TYPE = 'mempage'
This query works perfectly but I have written codes in first format. I want to know why this happens and is there any solution (Except what I said) to solve this problem?
The reason I don't want to use my solution is I have lots of written queries that I don't want to (or even cannot) change them! what I'm seeking is some king of options to set to connection (like set names 'latin1';
)