Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use update statement in MySQL Database

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Xiaobian to share with you how to use MySQL database update statement, I hope you have something to gain after reading this article, let's discuss it together!

1. The first type: update table a with table b data

update Player as a ,PlayerSet as bset a.role_id=b.set_value where a.role_id=b.set_key

2. The second type: also uses table b data to update table a, but the method is different.

update RoleSetset_key=(SELECT name FROM Player where id = RoleSet.set_value);

3. The third type: use the middle table to solve the following errors

Error Code: 1055. Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'xxxxxxx' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

4. Share a tip: Use variables to add non-repeating suffixes

set @i:=1;update Group SET name=CONCAT(name,'_', (@i:=@i+1))where name in(SELECT a.GroupNamefrom( SELECT name as GroupName FROM Group GROUP BY name HAVING count(*) > 1) as a);

This above content is MySQL database update all the content, see the addiction that practice a few times more than our future development career will definitely play a lot of help!

After reading this article, I believe you have a certain understanding of "how to use MySQL database update statement". If you want to know more relevant knowledge, welcome to pay attention to the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report