当前位置:网站首页>[SQL] at a certain correlation with a table of data update another table
[SQL] at a certain correlation with a table of data update another table
2022-07-30 04:16:00 【Is average】
Event
When writing a MySQL statement, I want to implement the function of "using the field value in one table to update the field value in another table"
The two tables are structured as follows:
t1 table:
t2 table:
After querying data, write the following statement:
update t1set aaa=t2.aaafrom t2where bbb=t2.bbb;
Error after execution:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from t2 where bbb=t2.bbb' at line 3
After querying the data, I found that the above writing method is the writing method of SQL Server, so an error will be reported in MySQL
Similarly written in MySQL:
update t1,t2set t1.aaa=t2.aaawhere t1.bbb=t2.bbb;
Summary
In MySQL, use the field value in one table to update the field value in another table:
update tabel_dest,table_srcset tabel_dest.attr = table_src.attrwhere condition;
In SQL Server, use the field value in one table to update the field value in another table:
update tabel_destset attr = table_src.attrfrom table_srcwhere condition;
边栏推荐
- Send it to your friends and let TA treat you to fried chicken!
- [Driver] udev aliases each serial port of USB to 4 serial ports
- Mini Program Graduation Works WeChat Points Mall Mini Program Graduation Design Finished Products (1) Development Overview
- 数组和结构体
- After 5 years of Ali internship interview~
- Go书籍大全-从初级到高级以及Web开发
- Flutter record learning different animation (2)
- 2022-07-29 Group 4 Self-cultivation class study notes (every day)
- 【驱动】udev为USB转4串口的每个串口起别名
- Usage of exists in sql
猜你喜欢
Pytorch framework learning record 7 - convolutional layer
Redis【超详解!!!】
Pytorch框架学习记录5——DataLoader的使用
day10--install mysql on linux
【转】Swift 中的面向协议编程:引言
(6) "Digital Electricity" - Diodes and CMOS Gate Circuits (Introduction)
High Concurrency Framework Disruptor
Reverse Theory Knowledge 3 [UI Modification]
网页元素解析a标签
sqlmap use tutorial Daquan command Daquan (graphics)
随机推荐
Arrays and Structures
New interface - API interface for "Taote" keyword search
WeChat second-hand transaction small program graduation design finished works (8) graduation design thesis template
Go书籍大全-从初级到高级以及Web开发
【C语言】程序环境和预处理
Alibaba search new product data API by keyword
2022.7.29-----leetcode.593
The first immersive and high-fidelity metaverse in China, Xiyuan Universe is officially launched
How to extract year, month and day data in date type in SQL Server
LeetCode 114. Expand Binary Tree into Linked List (One Question Three Eats)
(题目练习)条件概率+权值线段树+FWT+后缀数组
【C进阶】数组传参与函数指针
Send it to your friends and let TA treat you to fried chicken!
What is CDH/CDP?
cv2.polylines
弘玑再度入围Gartner 2022 RPA魔力象限并实现位置大幅跃升
How to compare struct, slice, map for equality and the difference between several comparison methods in golang
厦门感芯科技MC3172(1):介绍和环境搭建
恐造成下一个“千年虫”的闰秒,遭科技巨头们联合抵制
MySql 怎么查出符合条件的最新的数据行?