gpt4 book ai didi

mysql错误: use result of innerjoin into new query

转载 作者:行者123 更新时间:2023-11-30 23:11:05 24 4
gpt4 key购买 nike

我有 2 个要合并的 sql 字符串:

  • 第一个表有一个产品的所有数据
  • 第二个表(inner join)包含具有团体价格的产品的所有数据。

但我得到不同的结果

测试搜索“sku”

SELECT sku
FROM `c3eiwitlive`.`catalog_product_entity`
WHERE (
`entity_id` LIKE '%17086%'
)

group_price表上直接sql

结果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`
)

最佳答案

在我看来,'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`
)

关于mysql错误: use result of innerjoin into new query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19685096/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com