观察表 - O_ID,NAME,OL_ID,BP_ID,OC_ID和OL_ID,BP_ID,OC_ID这三列包含FK。
OBSERVATION_CATEGORY表 - OC_ID NAME
BUSINESS_PROCESS表 - BP_ID NAME
OPERATING_LOCATION_1 table-ID NAME
我有4个其他表,其中ID列必须插入观察表中。简而言之,我必须将4个表中的数据提取到一个表中。
答案 0 :(得分:0)
FIRST CREATE TABLE AND CREATE SQL QUERY LIKE below:-
INSERT INTO table5
SELECT O_ID,OC_ID, oc.NAME,BP_ID bp.NAME,ol.ID,ol.NAME
FROM table1 ob INNER JOIN table2 oc ON ob.O_ID=oc.OC_ID
INNER JOIN table3 bp ON ob.O_ID=bp.BP_ID
INNER JOIN table4 ol ON ob.O_ID=ol.ID;
How ever you have NOT mention your DATABASE nor your exact problem.