Firstly I'm starting to mess with mySQL now I'm very lazy on the subject yet
I have a table that is named products_search_items
and in this table there are 2 columns product_i"
and search_item_id
I needed to, for example, get all product_id
that has a search_item_id
value of 20 and 14
With this query I did I get all the search_item_id
of value 20 and show the product_id
with that search_item_id
SELECT id.product_id FROM products_search_items AS id
INNER JOIN products ON products.id = id.product_id
WHERE search_item_id = 20
For example here on this table
# product_id search_item_id
26 14
26 20
29 29
29 20
44 31
this query would return this:
# product_id
26
29
But I need it to return only the product_id
that have the search_item_id
value of 20 and 14. It must necessarily have two search_item_id
. If, for example, there is only one of them, then the product_id can not be returned.
So, in the above dataset would have to return something like this:
# product_id
26