SQL插入到多个表中的select

时间:2013-11-20 14:38:31

标签: sql oracle-sqldeveloper sql-insert

我有以下3个表,Data_Excel包含人名,地址,城市和来源;人员表有名称和ID;我需要在person_location中插入地址源,地址,城市和ID ...其中ID来自人员表,并且对于id存在的名称应该在data_excel表中匹配以获取所有细节

I have the following 3 tables, Data_Excel contains the names, address, city and source of person; Person table has the name and ID; I need to insert into person_location the address source, address, city and ID...where ID comes from person table and name that exist against the id should be matched in the data_excel table to get all the details

2 个答案:

答案 0 :(得分:1)

请查看此very similar question,其中应提供您应用于自己问题所需的信息。

答案 1 :(得分:1)

错误可能来自查询A.name, A.ID in (Select[...]

的这一部分

你可以试试..

INSERT INTO person_location 
SELECT A.ID,A.P_name,source,P_address,P_city,P_country from data_excel de, person A where A.name = de.c_name;

如果您需要ID > 6566条件,可以在最后添加。

INSERT INTO person_location 
SELECT A.ID,A.P_name,source,P_address,P_city,P_country from data_excel de, person A where A.name = de.c_name and ID > 6566;