INSERT的语法是:
insert into tableName1(col1,col2,......) values(val1,val2,.....)
SELECT的语法是:
select col1,col2,... from tableName2 where cond1 and cond2 and ....
利用insert和select的联合使用,可以将select语句的查询结果,插入到tableName1内。
联合使用的语法是:
insert into tableName1(col1,col2,......) select col1,col2,... from tableName2 where cond1 and cond2 and ....
来个今天做的实例:
select xwsydw_id,ksh,4,20,'无学位',137566,id from DataCoequalityMaster
where xwsydw_id=137566 and sqxwxslbm_id in
(select id from codecoequalitystudent where code in(1,3))
and
qzxwm_id in
(select id from codedegreesort where code='000')
insert into tableName1(col1,col2,......) values(val1,val2,.....)
SELECT的语法是:
select col1,col2,... from tableName2 where cond1 and cond2 and ....
利用insert和select的联合使用,可以将select语句的查询结果,插入到tableName1内。
联合使用的语法是:
insert into tableName1(col1,col2,......) select col1,col2,... from tableName2 where cond1 and cond2 and ....
来个今天做的实例:
select xwsydw_id,ksh,4,20,'无学位',137566,id from DataCoequalityMaster
where xwsydw_id=137566 and sqxwxslbm_id in
(select id from codecoequalitystudent where code in(1,3))
and
qzxwm_id in
(select id from codedegreesort where code='000')