Reputation: 105
I have a Customers Database in MS Access. I want to make a sql query that searches a substring from my primary key field.
For Example :
I want to select all the IDs that contain the number "35".
My DataBase before the SELECT statement :
My DataBase after the SELECT statement :
Is it possible ?
Upvotes: 0
Views: 1773
Reputation: 2574
Since the Access wildcard is *
and not %
and, AFAIK, Access doesn't support CONTAINS
I think you really want:
SELECT * FROM MyTable WHERE ID like "*35*"
Though based on our discussion in comments, other options (for when the ID
field isn't a string
) are:
SELECT * FROM MyTable WHERE Str(ID) like "*35*"
And
SELECT * FROM MyTable WHERE CStr(ID) like "*35*"
Upvotes: 2
Reputation: 146597
Assuming that the ID field is numeric,
In MsAccess:
Select * from myTable
where str(ID) like "*35*"
in SQL Server
Select * from myTable
where str(ID, 12, 0) like '%35%'
Upvotes: 0