Helpful Information
 
 
Category: Windows Help
MS Access and SQL

Hi -

I'm in the unfortunate position of having to run a SQL query through Access. What I'm trying to accomplish is to search for records that contain keywords within a text field. This is the query I have written:

SELECT TblBusinessInformation.FldComments, TblBusinessInformation.FldBusinessId,
TblBusinessInformation.FldCompanyName, TblBusinessInformation.FldBusinessAddress1,
TblBusinessInformation.FldBusinessAddress2, TblBusinessInformation.FldBusinessCity,
TblBusinessInformation.FldBusinessState, TblBusinessInformation.FldBusinessZipCode

FROM TblBusinessInformation
WHERE (((TblBusinessInformation.FldComments) Like "FEMA" & "SBA" Or
(TblBusinessInformation.FldComments) Is Null));

It doesn't seem to be returning the correct results. Can anyone see anything wrong with this? Also, is it possible to run a NOT LIKE?

Thanks,

Jd

SELECT TblBusinessInformation.FldComments, TblBusinessInformation.FldBusinessId,
TblBusinessInformation.FldCompanyName, TblBusinessInformation.FldBusinessAddress1,
TblBusinessInformation.FldBusinessAddress2, TblBusinessInformation.FldBusinessCity,
TblBusinessInformation.FldBusinessState, TblBusinessInformation.FldBusinessZipCode

FROM TblBusinessInformation
WHERE (((TblBusinessInformation.FldComments) Like "FEMA" & "SBA" Or
(TblBusinessInformation.FldComments) Is Null));

The bold text is where is see a possible problem. 1) I'm not sure about the double quotes, I've always used single quotes. Not sure if it matters or not, but I would assume it does. 2) The "like" argument is saying the entire field should be "fema" or whatever, not just a certain part of it. You want a different argument there, off the top of my head, I can't recall it. "IN" maybe??? Sorry bout the ramblin'.










privacy (GDPR)