字段列表中的列''不明确

时间:2019-01-10 12:51:29

标签: mysql sql

我收到错误

  

字段列表中的列expeertID不明确

我不确定如何解决此问题

INSERT INTO cv(expertID)
SELECT expertID 
FROM experts
INNER JOIN cv ON experts.expertID = cv.expertID;

3 个答案:

答案 0 :(得分:4)

尝试以下操作-由于两个表中都存在tablename,因此您需要添加expertID column

INSERT INTO cv(expertID)
SELECT experts.expertID 
FROM experts
INNER JOIN cv ON experts.expertID = cv.expertID;

答案 1 :(得分:3)

您需要将column nametablename指定要从哪个表中显示,或者指定insert所需的数据:

INSERT INTO cv(expertID)
     SELECT e.expertID 
     FROM experts e INNER JOIN 
          cv 
          ON e.expertID = cv.expertID;

答案 2 :(得分:0)

尝试一下!

我使用了表别名,然后在选择列表中用列明确提到了别名。现在,select中的expertID来自experts表,而不是模棱两可的。

INSERT INTO cv(expertID)
SELECT e.expertID 
FROM experts e
INNER JOIN cv  c ON e .expertID = c.expertID;