我正在尝试比较两个不同制造商之间的产品表中的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%"
答案 0 :(得分: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%"
答案 1 :(得分: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);