--需要table1存在
--where后面可以写关联子查询条件,也可以不写,mysql中不能写t1别名
insert into table1 t1(id, name)
select id,name from table2 t2
where t2.字段=t1.某字段;
--给项目插入全部学段,需要指定项目Id
insert into TBL_PROJECT_GRADE t1(id, project_id,grade_id)
select lower(sys_guid()) as id,'porjectId'as project_id,value as grade_id from TBL_BASE_DICT t
where module_id = '2'
db2下insert into table1后面似乎不能写别名
--select * into table2 from table1
--需要tmp_table不存在,新建,PL/SQL需要如下写法
create table tmp_table as
select id from tbl_project
--update select
update table1 t1 set t1.name =
(select name from table2 t2 wehre t2.id=t1.id)
子查询中引用外表的值,写在where后可以,写在表连接中的on后不行。