我想要组合2个sql字符串:
inner join
)包含具有组价格的所有产品数据。但是我得到了不同的结果
测试搜索'sku'
SELECT sku
FROM `c3eiwitlive`.`catalog_product_entity`
WHERE (
`entity_id` LIKE '%17086%'
)
group_price
表
结果269条记录
SELECT SKU, value
FROM `c3eiwitlive`.`catalog_product_entity_group_price` AS T1
INNER JOIN
`c3eiwitlive`.`catalog_product_entity` AS T2
ON T1.`entity_id` = T2.`entity_id`;
组合sql返回较少的记录
结果234条记录
SELECT name
FROM `c3eiwitlive`.`catalog_product_flat_1` AS T1
WHERE T1.`sku`
IN (
SELECT sku
FROM `c3eiwitlive`.`catalog_product_entity_group_price` AS T1
INNER JOIN `c3eiwitlive`.`catalog_product_entity` AS T2 ON T1.`entity_id` = T2.`entity_id`
)
答案 0 :(得分:0)
在我看来,'catalog_product_flat_1'表中缺少一些sku条目。 为什么不反转查询以识别丢失的行?
SELECT sku
FROM `c3eiwitlive`.`catalog_product_entity_group_price` AS T1
INNER JOIN `c3eiwitlive`.`catalog_product_entity` AS T2 ON T1.`entity_id` = T2.`entity_id`
WHERE sku
NOT IN (
SELECT sku from `c3eiwitlive`.`catalog_product_flat_1`
)