我试图离开联接查询,它失败,并显示以下消息:
“ on子句”中的未知列“ seller_product.seller_product_id”
这是查询:
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/