当前位置:网站首页>SQL update批量更新
SQL update批量更新
2022-06-27 18:36:00 【墨天輪】
首先回顧下,sql update語句是用於修改錶中的數據。
語法:
UPDATE 錶名稱 SET 列名稱 = 新值 WHERE 列名稱 = 某值
SQL update批量更新實例
1、通過同一錶內update複制列到另一列,如下圖所示,在原錶增加列score2,且把score的值複制過來

update student set score2= score
輸出結果

如果是异錶數據更新過來呢?應該怎麼操作?請往下看~
2、特殊情况下,某錶需要增加列外鍵與另一錶(可能是另一個庫的錶)關聯,這種情况由於沒有關聯性,往往通過紙質資料做電子錶格再做臨時錶來通過批量更新關系數據
如student 錶,需要增加列grade_id

另一張臨時錶Grade錶(可能是電子錶格導入的臨時錶)如下:

現需求在student錶上增加的Grade_id對應賦值,語句如下 :
update studentset grade_id = (select grade_id from grade a where a.student_id=student.id)where student.id in (select student_id from grade)
輸出結果如下:

update有風險,操作須謹慎!朋友們

边栏推荐
- Android kotlin learning
- leetcode 142. Circular linked list II
- [UVM foundation] build of UVM_ Phase execution sequence
- Leetcode 704. Binary search
- Bit.Store:熊市漫漫,稳定Staking产品或成主旋律
- About redis master-slave replication
- Advanced learning of MySQL -- Application -- view, stored procedure, trigger
- Teach you to use elastic search: run the first hello world search command
- (5) SPI application design and simulation verification 2 - design code implementation
- Shardingsphere & Atlas & MYCAT comparison
猜你喜欢

Part 31 supplement (31) ECMAScript conversion to string and number

428-二叉树(501.二叉搜索树中的众数、701.二叉搜索树中的插入操作、450.删除二叉搜索树中的节点、669. 修剪二叉搜索树)

银河麒麟V10系统激活

Hospital reservation and registration system - system structure

GAC Mitsubishi's new outlander made its first domestic debut in the year, and its product strength was fully renewed

Asemi rectifier bridge kbp210 parameters, kbp210 specifications, kbp210 dimensions

ROS "topic" programming implementation
![[UVM foundation] UVM_ Is in agent_ Active variable definition](/img/55/a14fbde43b25ccdc5a7996121396f9.jpg)
[UVM foundation] UVM_ Is in agent_ Active variable definition

The data synchronization tool dataX has officially supported reading and writing tdengine

国产数据库认证考试指南汇总(2022年6月16日更新)
随机推荐
Asemi rectifier bridge kbp307 parameters, kbp307 details, kbp307 pictures
Leetcode 704. Binary search
The power of code refactoring: how to measure the success of refactoring
07. Express routing
Explain the distributed computing of Apache skywalking OAP in detail
Android kotlin learning
GAC Mitsubishi's new outlander made its first domestic debut in the year, and its product strength was fully renewed
Handwritten promise series - all
Study on heritability and field experiment design
【ELT.ZIP】OpenHarmony啃论文俱乐部—见证文件压缩系统EROFS
Hospital reservation and registration system - system structure
Part 32 supplement (32) string of ECMAScript
国产数据库认证考试指南汇总(2022年6月16日更新)
ROS "topic" programming implementation
Oracle的NUMBER长度超过19之后,实体使用Long映射,导致出现问题是为什么?
[UVM foundation] build of UVM_ Phase execution sequence
Three methods to quickly open CMD in a specified folder or place
Leetcode 46 Full Permutation
leetcode 82. Delete duplicate Element II in the sorting linked list
建立自己的网站(10)