Access SQL- SELECT WHERE text exists in the string

Posted on 2011-05-10
Last Modified: 2012-05-11

Hi. I want to convert the following SQL statement so that if "PARENT" exists [Apllicable to] it selects that record. Do I use the Instr function or is there a better function? In other words if
[Applicable to] contained "PARENT,STAFF" then it would select that records

sSQL= "SELECT * FROM [Table1] WHERE [Applicable to] = ' PARENT'"
Question by:murbro
    LVL 39

    Accepted Solution

    sSQL= "SELECT * FROM [Table1] WHERE [Applicable to] like '%PARENT%'"
    LVL 142

    Assisted Solution

    by:Guy Hengel [angelIII / a3]
    sSQL= "SELECT * FROM [Table1] WHERE [Applicable to] LIKE '*PARENT*' "
    or better logic:

    sSQL= "SELECT * FROM [Table1] WHERE ',' & [Applicable to] & ',' LIKE '*,PARENT,*'"

    you might need to use % instead of * if it's ms sql server and not ms access, and + instead of the & also ...


    Author Closing Comment

    Thanks very much

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
    How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now