Avatar of Lmillard
Lmillard
 asked on

MySql AND / OR selection whilst using IN

Hi,

I am using IN with a query of mine to select products based on variant filters and I have noticed that it selects very much like the OR operator. is there a way to make this work the same as AND?

Query is very much like the attached code

Regards
Leigh
SELECT 
        DISTINCT(prodCode),
        RosettePadding,
        RosetteText,
        TitleDesc 
        FROM products 
        WHERE filterOptionID IN(1,20,25,13,19)
        ORDER BY TitleDesc, SortOrd, ProdCode

Open in new window

MySQL ServerSQL

Avatar of undefined
Last Comment
Lmillard

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Guy Hengel [angelIII / a3]

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Lmillard

ASKER
Thanks for coming back so quickly with such a thorough answer.

The query I have shown is actually a Coldfusion cached result set hence appearing non normalized. The actual data is stored in filterGroup and filterGroupOptions to allow 1 row per product option and multiple product rows to allow multiple filters.

The full set of queries is also taking into account pagination and sortation variables being fired in so though I would make it as easy to understand for everyone and backwards engineer the solution.

Thanks for your help on this one, I can now see a bit of re-coding happening but can know see the path to follow.

Cheers
Leigh
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck