update a set id=(select b.id from a,b where a.id=b.id) where exist(select 1 from a,b where a.id=b.id)
update a set col_sql=(select ... from b where a.id=b.id and a.id=1 and a.col>b.col)
update a set 列=(select 列 from b where a.id=b.id and a.id=1)楼主的题目似乎有问题表a,b通过id关连。想update a的id到b的id ----------------- 按这两句似乎没有必要update,既然是相同的,又update做什么? ,条件a.id=b.id and a.id=1 ----------------------------- 按这句,只要 update a set id=1
表a,b通过id关连。想update a的id到b的id, 条件a.id=b.id and a.id=1确定了你要update的数据为a.id和b.id 都为1的。 那么你的表也就不用update了,按照你的条件,你的update什么作用都起不了啊。
条件有问题: “条件a.id=b.id and a.id=1”=》a.id=1 and b.id=1
set
id=(select b.id from a,b where a.id=b.id)
where exist(select 1 from a,b where a.id=b.id)
-----------------
按这两句似乎没有必要update,既然是相同的,又update做什么?
,条件a.id=b.id and a.id=1
-----------------------------
按这句,只要 update a set id=1
条件a.id=b.id
and a.id=1确定了你要update的数据为a.id和b.id 都为1的。
那么你的表也就不用update了,按照你的条件,你的update什么作用都起不了啊。
“条件a.id=b.id and a.id=1”=》a.id=1 and b.id=1
有两个表clear_temp和clearusr,两个表的acct_id相关联,但clearusr的acct_id比clear_temp的acct_id多,即clearusr的acct_id包括了clear_temp的act_id,问题是想根据clear_temp,改clearusr的cust_id,即改成clear_temp里cust_id的值,但只改clearusr里cust_id=1的记录。
请问要怎样写sql?