gpt4 book ai didi

mysql - 嵌套左连接查询不起作用

转载 作者:行者123 更新时间:2023-11-29 18:57:02 26 4
gpt4 key购买 nike

我尝试左连接查询,但失败并显示消息:

Unknown column 'seller_product.seller_product_id' in 'on clause'

这是查询:

SELECT sp.seller_product_id FROM seller_product 
LEFT JOIN (
SELECT spov.seller_product_id
FROM seller_product_option_value spov
WHERE spov.active = 1
AND spov.seller_product_id IN ( 2567 ) ) AS option_query
ON seller_product.seller_product_id = option_query.spov.seller_product_id

最佳答案

您需要为您的表添加别名,请尝试以下操作:

SELECT sp.seller_product_id FROM seller_product sp
LEFT JOIN (
SELECT spov.seller_product_id
FROM seller_product_option_value spov
WHERE spov.active = 1
AND spov.seller_product_id IN ( 2567 ) ) AS option_query
ON sp.seller_product_id = option_query.spov.seller_product_id

关于mysql - 嵌套左连接查询不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44086712/

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