Keith wrote:


g'day,

i'm looking for a way to do two BETWEEN ranges. Currently I have
sys.sectorID BETWEEN 1 AND 20 but I want it so that I can search between
1 and 20 and also between 30 and 42 but all my efforts net an error and
the manual doesn't go into a lot of detail. If there's a faster way than
BETWEEN then 'll take it.

Cheers,
Keith

SELECT * FROM sys WHERE sectorID BETWEEN 1 AND 20 OR sectorID BETWEEN 30 AND 42;

If that's slow (the optimizer doesn't like ORs) and you are using at least mysql 4.0.0, you can change this to

SELECT * FROM sys WHERE sectorID BETWEEN 1 AND 20
UNION
SELECT * FROM sys WHERE sectorID BETWEEN 30 AND 42;

Michael


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to