1. 程式人生 > >MySQL UPDATE子查詢

MySQL UPDATE子查詢


 - update services a,(select concat(services_time,'分鐘') as
   services_time,services_id from services) b set a.services_time =
   b.services_time where a.services_id=b.services_id

說明:
1、update 時,更新的表不能在set和where中用於子查詢;
2、update 時,可以對多個表進行更新(sqlserver不行);
如:update ta a,tb b set a.Bid=b.id ,b.Aid=a.id;
3、update 後面可以做任意的查詢,這個作用等同於from;