如何提取数据对应的查询

时间:2015-06-03 12:51:17

标签: mysql

如何提取相应查询的数据: "multiple_option_id=10""multiple_option_id=1074"并返回与此查询对应的"product_id"

link to img

3 个答案:

答案 0 :(得分:1)

这有两种可能性

  • 获取product_id multiple_option_id 10或1024

  • 获取product_id multiple_option_id,其中包含10或1024

对于第一种情况,它相当简单

select product_id from table_name 
where multiple_option_id in (10,1024) 

对于第二种情况,它将是

select product_id from table_name 
where multiple_option_id in (10,1024) 
group by product_id having count(*) = 2 

答案 1 :(得分:0)

 select product_id from table 
 where multiple_option_id in (10,1024) 

答案 2 :(得分:0)

var query = data.GroupBy(item => item.Distance)
    .SelectMany(group => group.OrderBy(Guid.NewGuid()));