Weird LIKE issue

Kinroan

New member
Local time
Today, 12:27
Joined
May 10, 2013
Messages
2
Weird LIKE issue [SOLVED]

Alright, so I'm doing a project for a business for school. My queries were working fine before another group changed the Database I was working with so I had to redo some things.

The thing is, it's a super-simple query that worked just fine yesterday and I don't even think they've changed that part of the DB, but it doesn't work now.

SELECT CustomerID, FirstName, LastName, Phone FROM [Customer Information] WHERE 'Last Name' LIKE 'x%'

I've tried using the [Customer Information].CustomerID format for the fields, 'LastName', and LastName as well as a few other variations I can't even recall. The odd thing is, it works just fine if I leave off the LIKE statement and there's only 3 records I'm testing with. I've checked my spelling a few dozen times, and I'm at my wit's end. :banghead:

If anyone has ANY ideas of any sort, I would appreciate it very much. I've attached a screen of the table. I feel like I have to be missing something obvious.

Also, my macros were acting weird earlier and I saw that there was an update for Access 2013 so I ran that and rebooted and they're fine now.

Thanks for any insight
 

Attachments

  • Customer.png
    Customer.png
    5 KB · Views: 81
Last edited:
Welcome to the forum.

Have you tried using the * wild-card character in place of the %
 
Try;
Code:
SELECT CustomerID, FirstName, LastName, Phone FROM [Customer Information] WHERE [B][COLOR="Red"][[/COLOR][/B]Last Name[COLOR="Red"][B]][/B][/COLOR] LIKE 'x*'
 
The field Last Name has no space in it :banghead: try;
Code:
SELECT CustomerID, FirstName, LastName, Phone FROM [Customer Information] WHERE LastName LIKE 'x*'
 
LastName definitely should not have quote marks around it since it is a fieldname not a string value. The field name should have square brackets.

One you fix this your query should return [Last Name] records that begin with x.

If it is a passthrough query to a database server or an ADO command then use the %.
If the query is run in Access on linked table then you need the *.
 
Wow guys, thanks! I was passing it through ADO, and when it didn't work I went to access to more simply test it and I had forgotten about it using the * instead of %. >.<

Thanks again everyone for the quick replies!
 

Users who are viewing this thread

Back
Top Bottom