Link to home
Start Free TrialLog in
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

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lmillard
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