以下MySQL 5.7.19脚本引发错误Error Code: 1054. Unknown column 'ps.employeeId' in 'on clause'
。
SELECT
`ps`.`employeeId`
FROM
tablePS AS `ps`,
tableFO AS `fo`
LEFT JOIN
tableWA AS `wa`
ON
`wa`.`employeeId` = `ps`.`employeeId`
脚本运行没有错误是我删除了FROM子句中的第二个表
,
tableFO AS `fo`
或替换ON子句
`wa`.`employeeId` = `ps`.`employeeId`
与
`wa`.`employeeId` = 4
您可以使用这些命令
创建表CREATE TABLE tablePS (
`id` INT UNSIGNED auto_increment,
`employeeId` INT UNSIGNED,
PRIMARY KEY `id` (`id`)
);
CREATE TABLE tableFO (
`id` INT UNSIGNED auto_increment,
PRIMARY KEY `id` (`id`)
);
CREATE TABLE tableWA (
`id` INT UNSIGNED auto_increment,
`employeeId` INT UNSIGNED,
PRIMARY KEY `id` (`id`)
);
出了什么问题?
答案 0 :(得分:1)
尝试
SELECT
`ps`.`employeeId`
FROM
tablePS AS `ps`
CROSS JOIN
tableFO AS `fo`
LEFT JOIN
tableWA AS `wa`
ON
`wa`.`employeeId` = `ps`.`employeeId`