我在将一个表的值插入另一个表时遇到问题。
构建test.db:
CREATE TABLE CORE_information
(Department REAL,
PERSON TEXT);
CREATE TABLE SKILLS_detailed
(Department REAL,
PERSON TEXT,
SKILLS TEXT,
Line_Manager TEXT);
CREATE TABLE ALL_HR_skills
(Department REAL,
PERSON TEXT,
SKILLS TEXT);
INSERT INTO Core_information (Department, Person) VALUES (1, 'George');
INSERT INTO Core_information (Department, Person) VALUES (1, 'Alan');
INSERT INTO Core_information (Department, Person) VALUES (2, 'Maria');
INSERT INTO Core_information (Department, Person) VALUES (2, 'Andrea');
INSERT INTO SKILLS_detailed (Department, Person, Skills, Line_Manager) VALUES (1, 'George', 'Skill 1', 'A' );
INSERT INTO SKILLS_detailed (Department, Person, Skills, Line_Manager) VALUES (1, 'George', 'Skill 1', 'B' );
INSERT INTO SKILLS_detailed (Department, Person, Skills, Line_Manager) VALUES (1, 'Alan', 'Skill 1', 'A' );
INSERT INTO SKILLS_detailed (Department, Person, Skills, Line_Manager) VALUES (1, 'Alan', 'Skill 1', 'B' );
INSERT INTO SKILLS_detailed (Department, Person, Skills, Line_Manager) VALUES (2, 'Maria', 'Skill 1', 'A' );
INSERT INTO SKILLS_detailed (Department, Person, Skills, Line_Manager) VALUES (2, 'Maria', 'Skill 1', 'B' );
INSERT INTO SKILLS_detailed (Department, Person, Skills, Line_Manager) VALUES (2, 'Maria', 'Skill 1', 'C' );
INSERT INTO SKILLS_detailed (Department, Person, Skills, Line_Manager) VALUES (1, 'Andrea', 'Skill 1', 'A' );
INSERT INTO SKILLS_detailed (Department, Person, Skills, Line_Manager) VALUES (1, 'Andrea', 'Skill 1', 'B' );
INSERT into ALL_HR_skills (Department, Person)
SELECT Department, Person
FROM Core_information;
我需要在表格中添加ALL_HR_Skills SKILLS_detailed表格的第一个SKILL。 给我错误的代码就是这个:
INSERT INTO ALL_HR_skills(SKILLS)
SELECT SKILLS
FROM SKILLS_detailed
INNER JOIN ALL_HR_SKILLS
ON DEPARTMENT.ALL_HR_SKILLS = DEPARTMENT.SKILLS_DETAILED
AND PERSON.ALL_HR_SKILLS = PERSON.SKILLS_DETAILED;
Error: ambiguous column name: SKILLS
SKILLS_detailed和ALL_HR_skills表共享列名的问题是什么? 如何使INSERT SELECT和FROM语句在列和表上更具体?