当前位置:网站首页>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有風險,操作須謹慎!朋友們

边栏推荐
- wheel ui
- Advanced learning of MySQL -- Application -- Optimization of other SQL statements
- (POJ - 1847) tram (shortest circuit)
- OpenSSF 安全计划:SBOM 将驱动软件供应链安全
- Seata server database connection user and service database undo_ What permissions do log users need?
- leetcode 82. Delete duplicate Element II in the sorting linked list
- Defiato is an innovation that combines user-friendly features of a centralized platform with defi services
- Contest3182 - the 39th individual training match for 2021 freshmen_ F: ss
- [JS reverse hundreds of examples] I love to solve 2022 Spring Festival problems and receive red envelopes
- Contest3182 - the 39th individual training match for 2021 freshmen_ E: ringring
猜你喜欢

Tdengine connector goes online Google Data Studio store

Bit.Store:熊市漫漫,稳定Staking产品或成主旋律

Contest3182 - the 39th individual training match for 2021 freshmen_ F: ss

WOx WPM installing the Youdao plug-in

Redis installation

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

Wechat applet association search

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

CDH cluster installation

Shardingsphere & Atlas & MYCAT comparison
随机推荐
Explain the distributed computing of Apache skywalking OAP in detail
国产数据库认证考试指南汇总(2022年6月16日更新)
Byte + Google super full kotlin learning King fried notes! Kotlin introductory tutorial + Advanced kotlin enhanced actual combat (with demo)
Explain the distributed computing of Apache skywalking OAP in detail
Market status and development prospect of 4-butyl resorcinol used in skin care industry in the world in 2022
Redis installation
How to turn off the server terminal name of vscode
TP5 restrict access frequency
Contest3182 - the 39th individual training match for 2021 freshmen_ F: ss
About redis master-slave replication
Overview of Inspur Yunxi database executor
医院预约挂号系统-系统结构
[elt.zip] openharmony paper Club - witness file compression system erofs
数据同步工具 DataX 已经正式支持读写 TDengine
「技术课堂」如何用 VSCode 从 0 到 1 改写 TDengine 代码
如何查看 MySQL 表的索引信息?
实现时序数据库(Time Series Database)在特定场景下“远超”通用数据库的难点
[leetcode] 2. Add two numbers (user-defined listnode), medium
详解 OpenTSDB 与 TDengine 在系统功能层面上存在的差异
Leetcode 704. Binary search