update的使用
(1)update基本使用
update 表 set 字段1 = '值1' where? 字段2='值2'
(2)update在一個表中更新的情況,如圖所示:
 
我想在ID=3出現時修改ID=2的字段3
update 表? set?? 字段3 ='值' where? ID =(select? 來源ID? from 表? where ID = '3')
(3)update多表關聯的情況
1
2
根據id,將表1的name填入到表2的Cname中
【1】UPDATE test2 SET Cname = test1.name FROM test1 WHERE test2.id = test1.id
【2】UPDATE test2 SET Cname = test1.name FROM test1 WHERE test1.id = test2.id
【3】UPDATE test2 SET Cname = test1.name FROM test1,test2 WHERE test2.id = test1.id
以上3中方法都可以
但是
UPDATE test2 SET Cname = test1.name FROM test2 WHERE test1.id = test2.id
此語句不正確
PS:有了新的使用方法,或者我用到了我會及時更新的~~~~
 
總結
 
                            
                        - 上一篇: 今年新型城镇化新看点:加快户籍改革 建设
- 下一篇: 软件测试英语面试场景,软件测试英文面试题
