Using The Like Operator In A Query

The Like operator is very versatile and can be used in several situations. For instance, let's suppose that each piece of inventory in your warehouse is identified by a part number that consists of two digits, a hyphen, two more digits, a second hyphen, and then two alpha characters. Furthermore, let's suppose that you want to see all the records for part numbers between 11-XX-XX and 12-XX-XX. You might waste a lot of time trying to come up with a Between statement, but the simplest solution is the Like operator. Use a criteria expression in the form:
Like "11*" Or Like "12*"

The resulting query will return any part number that begins with the string 11 or 12. Don't forget the * character, or you'll end up with a completely different (and useless) set.

Please remember that this expression won't work if you need to see all the records between two nonconsecutive values, such as 11 and 13.

This tip is extracted from Tipworld. For more tips on many other things visit their site called TipWorld.
home button   Just click on the button for the Tiproom's Home Page.
Date of last revision: 17 August 2001.