Results 1 to 4 of 4
  1. #1
    moon-ray is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    7

    Use of Like within in opertor in WHERE clause

    I am building an SQL statement from selections in a form. One of the options on the form is address field. The field to specify the address is a multiple selection listbox. Because of the structure of the address, I need to use the LIKE operator. I have good code to use the IN operator. What I tried was "=In(Like "*31*", Like "*70*")" but it does not work. If I use just the values in the In( ), it works with missing the where those strings are in the list. If I use the Or operator with the Likes individually listed, it works. It just won't work. Is there a way to make this work.

    Thanks, in advance

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I have never tried wildcards with the IN operator. Don't think it will work. An SQL statement using the IN operator would look like this.
    Code:
    SELECT MyTable.Field
    FROM MyTable
    WHERE MyTable.Field IN ('foo', 'bar', 'baz')
    So if wildcards were acceptable it would be like this ...
    Code:
    SELECT MyTable.Field
    FROM MyTable
    WHERE MyTable.Field IN ('foo*', '*bar*', '*baz')
    I did a quick little search and I think the best solution is to use the OR operator. Another approach might be a UNION as explained in answer #39 here ...
    http://stackoverflow.com/questions/1...for-sql-server

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Also review http://allenbrowne.com/ser-50.html

    Use of = sign with IN is certainly not appropriate.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    moonray,

    I suggest you give us a more detailed description of what you are trying to do, and a sample of your data (the raw address data) and a corresponding desired result(based on that raw data).

Please reply to this thread with any new information or opinions.

Similar Threads

  1. WHERE clause
    By fabiobarreto10 in forum Forms
    Replies: 5
    Last Post: 04-12-2012, 02:42 PM
  2. Using Where Clause
    By mbrinser in forum Programming
    Replies: 2
    Last Post: 12-29-2011, 04:09 PM
  3. Not In Clause
    By dukect in forum Queries
    Replies: 10
    Last Post: 08-29-2011, 04:55 PM
  4. Using the TOP clause
    By WSlepecki in forum Queries
    Replies: 1
    Last Post: 04-08-2011, 06:59 AM
  5. Help on WHERE clause
    By QBCM in forum Programming
    Replies: 1
    Last Post: 12-19-2005, 08:43 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums