0

我正在尝试比较 2 个不同制造商之间的产品表中的 product_models。我发现同一产品有 2 个不同的 product_model 编号。相似但仍然不同。例如,制造商 1 (ELD) 的 CNELD-1004 与制造商 2 (MC) 的 1004 是相同的产品。我试图展示来自制造商 2 的产品,它与来自制造商 1 的 product_model 不同

不使用php,有没有办法做到这个mysql?

select products_model  AS MCProducts from products where manufacturers_id = 2; 

select products_model  AS ELDProducts from products where manufacturers_id = 1; 

Select  MCProducts from products WHERE MCProducts  not LIKE  "%ELDProducts%"
4

2 回答 2

0

选择 products_model, CASE

  WHEN manufacturers_id = 2 THEN 'MCProducts' 
  WHEN manufacturers_id = 2 THEN 'ELDProducts'
  END 
from products where WHERE MCProducts  not LIKE  "%ELDProducts%"
于 2013-04-25T04:42:33.397 回答
0

我想这也会起作用。

select products_model  AS MCProducts from products where manufacturers_id = 2 and     products_model not in (select products_model  from products where manufacturers_id = 1);
于 2013-04-25T04:45:01.577 回答