I\'m executing the following query
SELECT COUNT(*)
FROM table
WHERE field1=\'value\' AND (field2 >= 1000 OR field3 >= 2000)
There is
I'm new here, so I can't comment on other people's posts, but this is related to the posts by David M. and soulmerge.
The temporary table is not necessary. The UNION David M. suggested does not double count, as UNION implies a distinct (i.e. if a row exists in one half of the union, ignore it in the other). If you used UNION ALL, you would get two records.
The default behavior for UNION is that duplicate rows are removed from the result. The optional DISTINCT keyword has no effect other than the default because it also specifies duplicate-row removal. With the optional ALL keyword, duplicate-row removal does not occur and the result includes all matching rows from all the SELECT statements.
http://dev.mysql.com/doc/refman/5.0/en/union.html