gpt4 book ai didi

mysql - 来自多个数据库的 INNER JOIN 上的未知字段

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

我有以下sql语句:

INSERT INTO wk1_tbl (shohin_code, shohin_mei, variation_flag)                                                                                   
SELECT ha.HINCD, ha.HINNMA, if (g.goods_para_id IS NULL, 0, 1) AS variation
FROM ( SELECT KOSHINCD, count(HINCD) AS quatity
FROM sc.HINMTF
GROUP BY KOSHINCD ) AS group_set
INNER JOIN sc.HINMTA ha
ON ha.HINCD = group_set.KOSHINCD
INNER JOIN master_hankoya.goods g
ON ha.WEBHINID = g.goods_id 
WHERE ha.HINKB = '2' and ha.DATKB <> '9';

我在多数据库上使用 INNER JOIN,这样你可以看到 scmaster_hankoya 是不同的数据库当我运行它时,出现错误:

“on 子句”中的未知列“g.goods_id”

可以看到表master_hankoya.goodsg别名,goods_id是其中的一列

我想我对 INNER JOIN 有问题

请帮我改正

更新:我再次检查并采取了一个愚蠢的问题,在查询中有一个特殊字符使其无法运行

最佳答案

试试这个

INSERT INTO wk1_tbl (shohin_code, shohin_mei, variation_flag)                                                                                   
SELECT ha.HINCD, ha.HINNMA, if (g.goods_para_id IS NULL, 0, 1) AS variation
FROM ( SELECT KOSHINCD, count(HINCD) AS quatity
FROM sc.HINMTF
GROUP BY KOSHINCD ) AS group_set
INNER JOIN sc.HINMTA ha
ON ha.HINCD = group_set.KOSHINCD
INNER JOIN
(select * from master_hankoya.goods ) g
ON ha.WEBHINID = g.goods_id
WHERE ha.HINKB = '2' and ha.DATKB <> '9';

关于mysql - 来自多个数据库的 INNER JOIN 上的未知字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33361825/

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