【发布时间】:2020-04-02 21:41:37
【问题描述】:
我正在努力将两个表中的数据插入到一个表中,但我收到此错误“SQL 错误:ORA-00917:缺少逗号”,但我不知道问题出在哪里:欢迎任何帮助,谢谢。
INSERT INTO NAME_PROFFESION(NAME_ID AS 'NAME ID' , PROFFESION_ID AS 'PROFFESIONID' )
SELECT NAME_ID, PROFFESION_ID
FROM NAME
INNER JOIN PROFFESION
ON NAME.PROFFESION_ID = PROFFESION.PROFFESION_ID;
错误:
Error starting at line : 107 in command -
INSERT INTO NAME_PROFFESION(NAME_ID AS 'NAME ID' , PROFFESION_ID AS 'PROFFESIONID' )
SELECT NAME_ID, PROFFESION_ID
FROM NAME
INNER JOIN PROFFESION
ON NAME.PROFFESION_ID = PROFFESION.PROFFESION_ID
Error at Command Line : 107 Column : 37
Error report -
SQL Error: ORA-00917: missing comma
00917. 00000 - "missing comma"
*Cause:
*Action:
如果我删除 AS,我会收到该错误:
Error starting at line : 107 in command -
INSERT INTO NAME_PROFFESION(NAME_ID , PROFFESION_ID )
SELECT NAME_ID, PROFFESION_ID
FROM NAME
INNER JOIN PROFFESION
ON NAME.PROFFESION_ID = PROFFESION.PROFFESION_ID
Error at Command Line : 108 Column : 17
Error report -
SQL Error: ORA-00918: column ambiguously defined
00918. 00000 - "column ambiguously defined"
*Cause:
*Action:
【问题讨论】:
-
我不认为
as是insert中列定义的一部分。 -
好的,我确实编辑了帖子
-
如前所述,
NAME_ID AS 'NAME ID'在插入语句的列列表中没有意义。此外,单引号用于字符串分隔符,因此如果您希望在其他查询中使用列别名,请记住使用双引号。
标签: sql oracle select sql-insert