MJH*_*MJH 1 mysql sql subquery
我有一个包含其规格产品的表。我在http://sqlfiddle.com/#!2/15575/1中创建了一个数据样本。我想要创建搜索表单,以便用户可以按其规格搜索产品。用户搜索具有RAM = 2和VGA = 512或VGA = 1的笔记本电脑。我写了一个查询,但是没有用。请帮助我。这个例子:结果:1525,1535,k5,k6

select product
from my_table
where (custom = 'Ram' and custom_value = '2')
or (custom = 'vga' and custom_value in ('1', '512'))
group by product
having count(distinct custom) = 2
Run Code Online (Sandbox Code Playgroud)
例:
http://sqlfiddle.com/#!2/15575/19