求更新数据库
我想把查询运算后的数据更新到一个新的数据表中。把以前的表删了。重新建一个表,再把数据填加进去。请高手给我看看。
selecet a+b as [列1],c/d as[列2] from 表1
create table m_name (id int,name varchar(4))insert into m_nameselect 1,'张三' union allselect 2,'李四' union allselect 3,'王五'select * from m_name/*id name----------- ----1 张三2 李四3 王五*/create table m_chengji (name varchar(4),kemu int,chengji int,id sql_variant)insert into m_chengjiselect '张三',1,95,null union allselect '张三',2,92,null union allselect '张三',3,91,null union allselect '李四',1,56,null union allselect '李四',2,76,null union allselect '李四',3,99,null union allselect '王五',1,57,null union allselect '王五',2,100,null union allselect '王五',3,67,nullselect * from m_chengji/*name kemu chengji id---- ----------- ----------- -----------张三 1 95 NULL张三 2 92 NULL张三 3 91 NULL李四 1 56 NULL李四 2 76 NULL李四 3 99 NULL王五 1 57 NULL王五 2 100 NULL王五 3 67 NULL*/update m_chengji set id = a.id from m_chengji b left join m_name a on a.[name]=b.[name]