Results 1 to 2 of 2
Thread: Partial match query using LIKE?
2010-03-19, 17:29 #1
- Join Date
- Mar 2010
- Albany, NY
- Thanked 0 Times in 0 Posts
I have a small MySQL database that has MS Access 2007 as its front end. One of the tables in that database contains address data across several fields. One of the fields is a zip code field called Zip. The field is 5 characters and is a text field.
I am trying to write a query that will prompt the user to enter the first FOUR digits of the zip code, which will then return all the records which match those four digits. For example, 1234 would return 12345, 12346, and 12347 and so on.
I know that Access supports [bracketed] input in queries, but I am not sure how it works for a partial match. I suspect something along the lines of:
SELECT * FROM vendors WHERE Zip LIKE [Enter 4 digits]%
But I know that query does not work, Access does not like the % symbol.
Can anyone tell me what would be the proper syntax for such a query that would allow the user to specify the first four digits and then return all the records matching those four digits?
2010-03-19, 17:51 #2
- Join Date
- Aug 2001
- Evergreen, CO, USA
- Thanked 60 Times in 60 Posts
If you are working with ODBC linked tables, you need to use the Access syntax rather than mySQL or ANSI Standard. The statement would look something like:
SELECT * FROM vendors WHERE Zip Like [Enter 4 digits] & "*"
The ampersand is used to concatenate the * character which is the wildcard character for Access to the SQL string.Wendell