Selecting against subsets of a list in MySQL

前端 未结 7 1884
谎友^
谎友^ 2021-01-12 07:21

I\'m quite a begginer and I have two tables: \"product\" and \"product attributes\".

Here\'s some imaginary data (the actual stuff involves more tables )

Pr

7条回答
  •  清酒与你
    2021-01-12 07:34

    Assuming your product table is called Product and the ID column in that table is just called Id:

    SELECT * from Product p where p.Id IN 
      (Select id_product from ProductAttributes where id_attribute in (21, 23, 24))
    

提交回复
热议问题