Let's say I have a table joining two tables ... like this:
id_product | id_category
-----------------
11 | 22
11 | 33
12 | 22
12 | 33
I want to get id_products (distinctly) according to the list of search category identifiers.
If I use the IN () clause, the id_categories list uses a logical OR.
How can I make a SELECT query have a logical AND for the list of sent id_categ ??
Example. I want all id_products belonging to categories 22 AND 33 (and possibly 5 more or more category identifiers)
I found this answer:
Using the MySQL IN clause as all-inclusive (AND instead of OR)
... but the query mixes more than 1 table ... I only need a query for one table, one of them.
source
share