SQL 语句实例 update set xx=(select...) insert into xx select from
//从其它表更新本某表字段 update dd_corpusers set departmentid = (select distinct (sec_gov_users.departmentid) from sec_gov_users where sec_gov_users.canviewall = '1' and sec_gov_users.parentid = dd_corpusers.parentid) 2, update cwzb_corp_app_tab t set t.corp_name = (select b.departmentname from dd_corpusers b where t.corp_hg = b.usercode) where exists (select 2 from dd_corpusers c where t.corp_hg = c.usercode) 当cwzb_corp_app_tab 存在 表dd_corpusers 中没有的usercode时 要加上这个"存在"条件的限制,否则可能会无法执行(有些可执行) 这里的 "update cwzb_corp_app_tab t set t.corp_name = " 是针对 " cwzb_corp_app_tab "表中的所有记录的更新 "where exists"才是对本表中记录的限制
//从其它表取记录插入本某表 insert into dd_corpusers (userid, usercode, username, userpassword, parentid, corp_cde, userhy, corp_name, corp_hg) select dd_users_userid.nextval, a.code, a.name, a.code, a.sheng, a.code, '1', a.name, a.code from (select a.name, a.code, b.sheng from zxcks a, (select distinct (name), sheng from zxck) b where a.name = b.name) a
//用本表字段更新本表其它字段 update users_tab a set a.code = (select b.userid from users_tab b where a.userid = b.userid) where a.username like '%%'
SQL 语句实例 update set xx=(select...) insert into xx select from//从其它表更新本某表字段update dd_corpusers set departmentid = (select distinct (sec_gov_users.departmentid) from sec_gov_users where sec_