oracle通过Insert Into查询其他表数据插入
插入多条数据,不需要加values
INSERT INTO PG_GROUP(id,name,PARENT_ID ,GROUP_TYPE ,DELETED ,CREATE_TIME ,ORDER_NUM ,FWLX)
SELECT a.ID ,a.QPMC,b.ID,1,0,NULL,'',2
FROM SP_PQXX a INNER JOIN PG_GROUP b ON a.XZQMC =b.NAME
INSERT INTO PG_GROUP(id,name,PARENT_ID ,GROUP_TYPE ,DELETED ,CREATE_TIME ,ORDER_NUM ,FWLX)
SELECT a.ID ,a.ZBBM ,b.ID,2,0,NULL,'',2
FROM SP_ZBXX a INNER JOIN SP_PQXX b ON b.PQBM = a.PQBM
--
DELETE FROM PG_GROUP pg WHERE ID IN ( SELECT b.ID
FROM SP_ZBXX a INNER JOIN PG_ZRZXX b ON b.SPZBBM = a.ZBBM)
INSERT INTO PG_GROUP(id,name,PARENT_ID ,GROUP_TYPE ,DELETED ,CREATE_TIME ,ORDER_NUM ,FWLX)
SELECT b.ID ,b.XMMC ,a.ID,3,0,NULL,'',2
FROM SP_ZBXX a INNER JOIN PG_ZRZXX b ON b.SPZBBM = a.ZBBM