In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
It is believed that many inexperienced people have no idea about how to use UPDATE update sentence in SQL. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Update statement
The Update statement is used to modify the data in the table.
Syntax:
UPDATE table name SET column name = new value WHERE column name = a value
For example:
Person table:
LastNameFirstNameAddressCityGatesBillXuanwumen 10BeijingWilsonChamps-Elysees
Update a column in a row
We add firstname for people whose lastname is "Wilson":
UPDATE Person SET FirstName = 'Fred' WHERE LastName =' Wilson'
Results:
LastNameFirstNameAddressCityGatesBillXuanwumen 10BeijingWilsonFredChamps-Elysees
Update several columns in a row
We will modify the address (address) and add the city name (city):
UPDATE Person SET Address = 'Zhongshan 23, City =' Nanjing'WHERE LastName = 'Wilson'
Results:
LastNameFirstNameAddressCityGatesBillXuanwumen 10BeijingWilsonFredZhongshan 23Nanjing
Update statement update of SQL (update data in the table)
1. Update all rows in the table
two。 Update specific rows in the table, be sure not to omit the WHERE clause when updating, otherwise all rows will be updated.
The update update statement is divided into three parts in the following format:
1 updated table
2 column names and new values
3 filter criteria to determine which rows to update
Single column:
UPDATE CustomersSET cust_email = 'kim@qq.com'WHERE cust_id =' 10000005'
Multiple columns:
UPDATE CustomersSET cust_email = 'kim@qq.com', cust_contact =' Sam Roberts'WHERE cust_id = '10000005'
That is, when you update multiple columns, you only need to use a SET command, with each column = value pair separated by a comma, and the last column without a comma.
Update warning!
Be extra careful when updating records! In the above example, if we omit the WHERE clause, it looks like this:
UPDATE CustomersSET cust_email = 'kim@qq.com'
Executing the above code changes the cust_email of all the data in the Customers table to kim@qq.com.
The execution of UPDATE without WHERE clause should be careful, and then be careful. We usually do this only if we replace it in bulk.
After reading the above, have you mastered how to use UPDATE update statements in SQL? If you want to learn more skills or want to know more about it, you are welcome to follow 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.