#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    NYC
    Posts
    5
    Rep Power
    0

    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
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Posts
    1
    Rep Power
    0
    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'.

IMN logo majestic logo threadwatch logo seochat tools logo