Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Like operator

Status
Not open for further replies.

jpl458

Technical User
Sep 30, 2009
337
US
Have a column in a table that contains various codes but I only want to look at the following codes in that column:
GP4_1/2H
GP4_1HR
GP4_1H_F
GP_IMP-A
GP_IMP-J

My Like clause is the following:

Like "GP4_*" Or Like "GP_*"
I get back all the right things but also get back:
GR10
XR10
FRMONE
FNYI
DOGEV, Etc

Read up on wildcards and like, but can't figure this out.

Windows 7 Access 10 Sql server 5 express

Thanks

jpl
 
Correction, the database is a Progress Database and the column in question is text.
jpl
 
I have simplified the LIKE to Like "GP4*" and it returns:
PEMP
GP4_1/2H
GP4_1/2H
GP4_1/2H
GP4_1/2H
DOGEV
GP4_1/2H
GP_IMP-A
GP4_1/2H
GP4_1/2H
GP4_1/2H
GP4_1/2H
GP4_1/2H
GP4_1/2H
GP_IMP-A
GP4_1/2H
GP4_1/2H
GP4_1/2H
GP4_1/2H
GP_IMP-A
GP4_1/2H
GP4_1/2H
GP4_1/2H
GP4_1/2H
GP_IMP-A
DOGEV, Plus other bad stuff later in the list.
SQL from QBE grid:
SELECT PUB_PMMEMBER.[PMM-PassType]
FROM PUB_PMMEMBER
WHERE (((PUB_PMMEMBER.[PMM-PassType]) Like "GP4*"));

Why would something that has no characters in the LIKE be returned?

Another Clue: If I join the table with another table, then the LIKE works fine. here is that SQL;
SELECT PUB_PMMEMBER.[PMM-PassType]
FROM PUB_PMMEMBER INNER JOIN PUB_RPGLDIST ON PUB_PMMEMBER.[PMM-Trxn] = PUB_RPGLDIST.[RPX-Trxn]
WHERE (((PUB_PMMEMBER.[PMM-PassType]) Like "GP4*"));

Is there some obtuse rule I don't understand?

jpl

 
Your SQL shows [PMM-PassType] while your column heading is PEMP. Are you using a lookup field in the table PUB_PMMEMBER? This could be masking/hiding the actual values.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top