Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search SQL statement

Status
Not open for further replies.

knuckle05

Programmer
Dec 17, 2001
247
CA
Hi All,

I need to perform a search on my DB and I am able to get exact matches like this:

Select * FROM myTable WHERE myField LIKE 'ABC*'

but now I need to return all records that fall between A-G, and then H-P and so on. Is there a way to search all records between those letters?

Can someone help me modify this SQL statement to allow me those results?

thx!!
 
A-G
Code:
SELECT * FROM myTable WHERE myField LIKE '[A-G]%'
H-P
Code:
SELECT * FROM myTable WHERE myField LIKE '[H-P]%'
Q-Z
Code:
SELECT * FROM myTable WHERE myField LIKE '[Q-Z]%'

Check out BOL (Books Online) for wildcard searches with the LIKE operator.

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top