从Sql表的单个ID中选择多个Itme

时间:2019-02-13 17:20:52

标签: sql sql-server

我有1个供应商的多个产品,供应商ID进入“产品”表,我想选择具有多个产品的供应商,帮帮我!我的大脑不起作用!

enter image description here

3 个答案:

答案 0 :(得分:1)

我认为您可以通过聚合来做您想做的事

select supplierid 
from table t
where MAMaterial in ('BUN', 'BEEF')
group by suppierid
having count(*) = 2;  -- number of materials in list

答案 1 :(得分:0)

您可以尝试

Select supplerid from table
where MAMaterial in ('BUN', 'BEEF')

select TOP 1 supplerid from table
where MAMaterial in ('BUN', 'BEEF')

答案 2 :(得分:0)

您可以使用Processing

  preGetTrailheads(turl);
}
async function preGetTrailheads(turl) {
  var ths = await getTrailheads(turl);
  console.log("trailheads promise");
  console.log(ths);
  addTrailheadsToMap(ths);

}
async function getTrailheads(turl) {
  var result = await $.ajax({
    url: turl,
    datatype: 'json'
  });

  return result;
}