Update Table1 Set Table1.Car=(select max(Table2.car) from Table2 where Table1.Name=Table2.Name) where exists(select Table2.car from Table2 where Table1.Name=Table2.Name) and Table1.Name in (Select Name from Table2 Group by Name Having Count(Car)=1);
▲修改表1中的某列,目标值需要到表2中查询update tb_wap_pijia2 /*添加IMSI号*/ set imsi=( select imsi from tb_mdn2imsi where mdn=tb_wap_pijia2.mdn ) where exists (select mdn from tb_mdn2imsi where mdn=tb_wap_pijia2.mdn) /*WHERE的目的是为了避免插入空值*/
update tb_wap_pijia2 set imsi=( select imsi from tb_mdn2imsi where mdn=tb_wap_pijia2.mdn ) where exists (select 1 from tb_mdn2imsi where mdn=tb_wap_pijia2.mdn)
update table1 a set a.car = (select car from table2 where (name,1) in (select b.name,count(1) from table2 b where a.name = b.name group by name)) 这个好象也行哇
where
exists(select Table2.car from Table2 where Table1.Name=Table2.Name) and
Table1.Name in (Select Name from Table2 Group by Name Having Count(Car)=1);
set imsi=( select imsi from tb_mdn2imsi
where mdn=tb_wap_pijia2.mdn )
where exists (select mdn from tb_mdn2imsi
where mdn=tb_wap_pijia2.mdn) /*WHERE的目的是为了避免插入空值*/
update tb_wap_pijia2 set imsi=( select imsi from tb_mdn2imsi
where mdn=tb_wap_pijia2.mdn )
where exists (select 1 from tb_mdn2imsi
where mdn=tb_wap_pijia2.mdn)
(select car from table2 where (name,1) in
(select b.name,count(1) from table2 b
where a.name = b.name
group by name))
这个好象也行哇