gpt4 book ai didi

mysql - on 子句中的列 'id_training' 不明确

转载 作者:行者123 更新时间:2023-11-29 06:36:03 26 4
gpt4 key购买 nike

我想显示 course_title 数据,但我得到:

'id_training' in on clause is ambiguous.

查询错误在哪里?

CREATE TABLE `examination` (
`id_exam` int(32) NOT NULL,
`class_name` varchar(100) NOT NULL,
`id_training` int(32) NOT NULL,
`id_question` int(32) NOT NULL,
`total` int(3) NOT NULL,
`exam_duration` int(5) NOT NULL,
`start` datetime NOT NULL,
`end` datetime NOT NULL,
`passing_grade` int(3) NOT NULL,
`id_user` int(32) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `training` (
`id_training` int(32) NOT NULL,
`course_code` varchar(25) NOT NULL,
`course_title` varchar(100) NOT NULL,
`training_time` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

查询:

SELECT e.id_exam
, e.class_name
, e.id_training
, e.total
, e.exam_duration
, e.start_exam
, e.end_exam
, e.passing_grade
, t.course_title
FROM examination e
INNER JOIN training t
ON id_training = course_tilte

最佳答案

此错误“on 子句中的列 'id_training' 不明确”的原因两个表中存在相同的列,因此由于指定where 子句 sql 中的 id_training 列对我应该采用哪个表感到困惑,因此始终使用别名指定。

SELECT e.id_exam
, e.class_name
, e.id_training
, e.total
, e.exam_duration
, e.start_exam
, e.end_exam
, e.passing_grade
, t.course_title
FROM examination e
JOIN training t
ON e.id_training = t.id_training

关于mysql - on 子句中的列 'id_training' 不明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53808787/

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