0
このクエリを実行しようとしましたが、列がtb_divisionsに存在してもエラーが発生しました。エラーコード:1054 'on clause'の 'try.tb_stores.division'列が不明です
誰かがこのエラーを解決する方法を私を助けることができます:
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`;
私はLEFT JOINを使用し、それでもエラー。 - 2.ストア移行あなたはちょうどあなたがこのエラーだ理由ですそのテーブル部門とクライアントではなくtb_storesを使用している
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`;
を'companycode'カラムは存在しないか、存在しません。 –
クエリは 'JOIN'操作のどの部分でも' tb_divisions'を使用しません。あなたはあなたが得た正確なエラーメッセージを投稿できますか? –
@TimBiegeleisen申し訳ありません。エラーを入力するのを忘れました。エラーは 'on clause'の中の 'try.tb_stores.division'列には不明です。 – John