当前位置:网站首页>SQL modification statement
SQL modification statement
2022-07-02 15:46:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
If we want to modify the data of tables in the database , At this time, we will use UPDATE sentence .
UPDATE The basic syntax of a sentence is :
UPDATE < Table name > SET Field 1= value 1, Field 2= value 2, … WHERE …;
for example , We want to update employees surface id=100 The record of last_name and salary These two fields , Write first UPDATE employees SET name=” eldest brother ”, salary = 54000, And then in WHERE Clause to write the filter conditions of the rows that need to be updated id=100:
namely UPDATE employees SET last_name=‘ eldest brother ’, salary=54000 WHERE employee_id=100;
– Before the change :
– After modification :
Here we find UPDATE Of the statement WHERE Conditions and SELECT Of the statement WHERE The conditions are actually the same , Therefore, multiple records can be updated at one time :
UPDATE employees SET last_name=‘TEST’, salary=54000 WHERE employee_id>=101 and employee_id<=105;
– Before the change :
– After modification :
stay UPDATE In the sentence , We can also use expressions when updating fields .
for example , Put all the 50000 For employees with a salary of more than yuan, add 666 element :
UPDATE employees SET salary=54000+666 WHERE salary >= 50000;
– Query results
among ,SET salary=54000+666 It's for the current line salary The value of the field is added 666.
If WHERE The condition does not match any record ,UPDATE Statements do not report errors , But no records will be updated .
UPDATE Statement can have no WHERE Conditions , for example :
UPDATE employees SET salary=54000+666
This is the time , All records of the entire table will be updated . therefore , In execution UPDATE Be very careful when making statements , It's better to use SELECT Statement to test WHERE Whether the condition filters out the desired recordset , And then use UPDATE updated .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/147718.html Link to the original text :https://javaforall.cn
边栏推荐
- [leetcode] 283 move zero
- Aike AI frontier promotion (7.2)
- floyed「建议收藏」
- 高考分数线爬取
- Experiment collection of University Course "Fundamentals of circuit analysis". Experiment 5 - Research on equivalent circuit of linear active two terminal network
- Leetcode skimming - remove duplicate letters 316 medium
- 怎样从微信返回的json字符串中截取某个key的值?
- beforeEach
- 【LeetCode】577-反转字符串中的单词 III
- 动态规划入门二(5.647.62)
猜你喜欢
The outline dimension function application of small motherboard
Why does the system convert the temp environment variable to a short file name?
Ant group's large-scale map computing system tugraph passed the national evaluation
【LeetCode】1254-统计封闭岛屿的数量
Wechat Alipay account system and payment interface business process
Leetcode skimming -- count the number of numbers with different numbers 357 medium
[leetcode] 1162 map analysis
全是精华的模电专题复习资料:基本放大电路知识点
【LeetCode】1905-统计子岛屿
03. Preliminary use of golang
随机推荐
[leetcode] 877 stone game
[leetcode] 1020 number of enclaves
Experiment collection of University "Fundamentals of circuit analysis". Experiment 6 - observation and measurement of typical signals
【LeetCode】1254-统计封闭岛屿的数量
Digital collection system development (program development) - Digital Collection 3D modeling economic model system development source code
[leetcode] 283 move zero
6092. Replace elements in the array
Add an empty column to spark dataframe - add an empty column to spark dataframe
Leetcode skimming -- sum of two integers 371 medium
提前批院校名称
[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)
6090. 极大极小游戏
[development environment] install the Chinese language pack for the 2013 version of visual studio community (install test agents 2013 | install visual studio 2013 simplified Chinese)
《大学“电路分析基础”课程实验合集.实验七》丨正弦稳态电路的研究
【LeetCode】877-石子游戏
Party History Documentary theme public welfare digital cultural and creative products officially launched
自定义异常
动态规划入门二(5.647.62)
2278. Percentage of letters in string
Experiment collection of University "Fundamentals of circuit analysis". Experiment 7 - Research on sinusoidal steady-state circuit