MS Access Like statement with multiple values

Posted on 2008-11-17
Last Modified: 2012-05-05
Hi All,

I am writing an access application for our company and have come across a problem thats been bugging me.

i need to do a like statement for 2 values in the same field

example i need to select products with the prefix 01 and 21

i tried this

SELECT ItemNumber FROM tblProducts WHERE ItemNumber Like '01*' AND ItemNumber Like 21

but it didnt work when i do a like with just 01 or just 21 it works fine, is there a way i can filter it by just these two?
Question by:paul612
    LVL 92

    Accepted Solution

    SELECT ItemNumber FROM tblProducts WHERE ItemNumber Like "01*" OR ItemNumber Like "21*"
    LVL 26

    Assisted Solution

    SELECT ItemNumber FROM tblProducts WHERE ItemNumber Like '01*' OR ItemNumber Like '21*'

    will brougt you alll the items with the prefixex 01 and 21.
    LVL 75

    Expert Comment

    by:DatabaseMX (Joe Anderson - Access MVP)
    SELECT ItemNumber FROM tblProducts WHERE ItemNumber IN (01,21)

    LVL 1

    Author Closing Comment

    I split the points as you both said the same thing at the exact same posting time, i didnt even think to try OR my brain isnt working today at all

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
    SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    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