I've got a series of filters that I would like to optimize and was wondering if anyone knows of a way to do this.
The syntax I'm using is for MSSQL/MS Access.
Here's the scenerio: I've got a database of ~5000 manufacturers that I would like to break down into groups based on the first character of the manufacturers name (i.e. '0-9', 'A-G', 'H-M', 'N-S', and 'T-Z')
The method I'm currently using works fine but I'd like to improve it if I can. Here is one of the current filters:
From what I've read about the IN Operator, it seems like it should do the trick; I'm afraid I just haven't found the right combination.
Here's what I've tried so far:
The first 3 statements resulted in "Missing Operator" errors and the final statement resulted in 0 (zero) records; but no error.
Can anyone think of other options? Or maybe another operator that will efficiently produce the results I'm looking for; without having the cumbersome select statement I currently have?
Thanks!!
ASPTard
The syntax I'm using is for MSSQL/MS Access.
Here's the scenerio: I've got a database of ~5000 manufacturers that I would like to break down into groups based on the first character of the manufacturers name (i.e. '0-9', 'A-G', 'H-M', 'N-S', and 'T-Z')
The method I'm currently using works fine but I'd like to improve it if I can. Here is one of the current filters:
Code:
SELECT * FROM tblManufacturers WHERE IsActive=TRUE AND Name LIKE '0%' OR Name LIKE '1%' OR Name LIKE '2%' OR Name LIKE '3%' OR Name LIKE '4%' OR Name LIKE '5%' OR Name LIKE '6%' OR Name LIKE '7%' OR Name LIKE '8%' OR Name LIKE '9%' ORDER BY Name ASC
From what I've read about the IN Operator, it seems like it should do the trick; I'm afraid I just haven't found the right combination.
Here's what I've tried so far:
Code:
SELECT * FROM tblManufacturers WHERE IsActive=TRUE AND Name IN LIKE ('0%', '1%', '2%', '3%', '4%', '5%', '6%', '7%', '8%', '9%') ORDER BY Name ASC
Code:
SELECT * FROM tblManufacturers WHERE IsActive=TRUE AND Name LIKE IN ('0%', '1%', '2%', '3%', '4%', '5%', '6%', '7%', '8%', '9%') ORDER BY Name ASC
Code:
SELECT * FROM tblManufacturers WHERE IsActive=TRUE AND Name IN (LIKE '0%', LIKE '1%', LIKE '2%', LIKE '3%', LIKE '4%', LIKE '5%', LIKE '6%', LIKE '7%', LIKE '8%', LIKE '9%') ORDER BY Name ASC
Code:
SELECT * FROM tblManufacturers WHERE IsActive=TRUE AND Name IN ('0%', '1%', '2%', '3%', '4%', '5%', '6%', '7%', '8%', '9%') ORDER BY Name ASC
The first 3 statements resulted in "Missing Operator" errors and the final statement resulted in 0 (zero) records; but no error.
Can anyone think of other options? Or maybe another operator that will efficiently produce the results I'm looking for; without having the cumbersome select statement I currently have?
Thanks!!
ASPTard