gpt4 book ai didi

mysql - 错误代码: 1054 Unknown column 'try.tb_stores.division' in 'on clause'

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

美好的一天,我尝试运行此查询,但遇到错误,即使该列确实存在于 tb_divisions 中。

有人可以帮我解决这个错误吗:

Unknown column 'try.tb_stores.division' in 'on clause?

-- 2.商店迁移

INSERT INTO `try`.`tb_stores`
(
`try`.`tb_stores`.`subscription`,
`try`.`tb_stores`.`client`,
`try`.`tb_stores`.`division`,
`try`.`tb_stores`.`code`,
`try`.`tb_stores`.`name`,
`try`.`tb_stores`.`location`,
`try`.`tb_stores`.`user`,
`try`.`tb_stores`.`created_at`,
`try`.`tb_stores`.`updated_at`
)
SELECT
1, -- subscription
`try`.`tb_clients`.`id` AS `client`, -- client
`try`.`tb_divisions`.`id` AS `division`, -- division
`dba_department`.`code`, -- code
`dba_department`.`descrip`, -- name
CONCAT('Region ',`dba_department`.`region_num`) AS region, -- location
2, -- user
NOW(), -- created_at
NOW() -- updated_at
FROM `test`.`dba_department`
LEFT JOIN `try`.`tb_clients`
ON `test`.`dba_department`.`company` = `try`.`tb_clients`.`companycode`;

enter image description here

我使用了 LEFT JOIN 但仍然出错。-- 2. 商店迁移

INSERT INTO `try`.`tb_stores`
(
`try`.`tb_stores`.`subscription`,
`try`.`tb_stores`.`client`,
`try`.`tb_stores`.`division`,
`try`.`tb_stores`.`code`,
`try`.`tb_stores`.`name`,
`try`.`tb_stores`.`location`,
`try`.`tb_stores`.`user`,
`try`.`tb_stores`.`created_at`,
`try`.`tb_stores`.`updated_at`
)
SELECT
1, -- subscription
`try`.`tb_clients`.`id` AS `client`, -- client
`try`.`tb_divisions`.`id` AS `division`, -- division
`dba_department`.`code`, -- code
`dba_department`.`descrip`, -- name
CONCAT('Region ',`dba_department`.`region_num`) AS region, -- location
2, -- user
NOW(), -- created_at
NOW() -- updated_at
FROM `test`.`dba_department`
LEFT JOIN `try`.`tb_clients`
ON `test`.`dba_department`.`company` = `try`.`tb_clients`.`companycode`
LEFT JOIN `try`.`tb_divisions`
ON `try`.`tb_stores`.`division` = `try`.`tb_divisions`.`id`;

最佳答案

您只使用表部门和客户,而不是tb_stores,这就是您收到此错误的原因:

enter image description here

关于mysql - 错误代码: 1054 Unknown column 'try.tb_stores.division' in 'on clause' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41844780/

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