Using Wildcards in a Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to wildcard on an account number in our database. The elements
in the account number are separated by a period (i.e. 4286.1WT.VS2). I want
to find all of the values with the VS2 ending but when I do a wildcard Like
"*VS2" I don't get any data. I have tried several different wildcard
characters and can't seem to get it to work. If I wildcard on Like
"4286*VS2" I don't get any data either. It seems like the periods separating
the elements are causing problems. Any suggestions?
 
I tried it and it works.

It will a great help for us to help you if you'll post the SQL

Does it look like

Select * From TableName
Where FieldName Like "*VSN"

Or, try this:

Select * From TableName
Where FieldName Like "%VSN"
 
I must be doing something wrong. I still can't get it to work. Here is the
SQL.

SELECT LIFESUPPORT_CHRG_ACCT_HIER.LEVEL_IND,
LIFESUPPORT_CHRG_ACCT_HIER.CHRG_ACCT,
LIFESUPPORT_CHRG_ACCT_HIER.PARENT_CHRG_ACCT,
LIFESUPPORT_CHRG_ACCT_HIER.DESCRIPTION
FROM LIFESUPPORT_CHRG_ACCT_HIER
WHERE (((LIFESUPPORT_CHRG_ACCT_HIER.PARENT_CHRG_ACCT) Like "*" & "VS2"));

Thanks for your help.
AB
 
I tried it and it works for me

Annette said:
I must be doing something wrong. I still can't get it to work. Here is the
SQL.

SELECT LIFESUPPORT_CHRG_ACCT_HIER.LEVEL_IND,
LIFESUPPORT_CHRG_ACCT_HIER.CHRG_ACCT,
LIFESUPPORT_CHRG_ACCT_HIER.PARENT_CHRG_ACCT,
LIFESUPPORT_CHRG_ACCT_HIER.DESCRIPTION
FROM LIFESUPPORT_CHRG_ACCT_HIER
WHERE (((LIFESUPPORT_CHRG_ACCT_HIER.PARENT_CHRG_ACCT) Like "*" & "VS2"));

Thanks for your help.
AB
 
Are you sure the filter is on the right field?.

Also try:

SELECT LIFESUPPORT_CHRG_ACCT_HIER.LEVEL_IND,
LIFESUPPORT_CHRG_ACCT_HIER.CHRG_ACCT,
LIFESUPPORT_CHRG_ACCT_HIER.PARENT_CHRG_ACCT,
LIFESUPPORT_CHRG_ACCT_HIER.DESCRIPTION
FROM LIFESUPPORT_CHRG_ACCT_HIER
WHERE (((LIFESUPPORT_CHRG_ACCT_HIER.PARENT_CHRG_ACCT) Like "%VS2"))
 
One more option you can try, does it return records

SELECT LIFESUPPORT_CHRG_ACCT_HIER.LEVEL_IND,
LIFESUPPORT_CHRG_ACCT_HIER.CHRG_ACCT,
LIFESUPPORT_CHRG_ACCT_HIER.PARENT_CHRG_ACCT,
LIFESUPPORT_CHRG_ACCT_HIER.DESCRIPTION
FROM LIFESUPPORT_CHRG_ACCT_HIER
WHERE Right(LIFESUPPORT_CHRG_ACCT_HIER.PARENT_CHRG_ACCT,3)="VS2"
 
There must be something with the actual data in my table that won't let the
wildcard work (it is set up as text). I created another table with the data
and manually retyped one of the account numbers in the field and the wildcard
worked for that entry only. I'll look some more at my actual data.

Thanks for your help!
AB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top