当前位置:网站首页>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
边栏推荐
猜你喜欢

Aike AI frontier promotion (7.2)

Custom exception

Why does the system convert the temp environment variable to a short file name?

Soul torture, what is AQS???

(Video + graphic) machine learning introduction series - Chapter 5 machine learning practice
![[network security] network asset collection](/img/3e/6665b5af0dedfcbc7bd548cc486878.png)
[network security] network asset collection

蚂蚁集团大规模图计算系统TuGraph通过国家级评测

Basic knowledge of cryptography
![[leetcode] 417 - Pacific Atlantic current problem](/img/30/c541bc1e81eb4e348ca11116a05e84.png)
[leetcode] 417 - Pacific Atlantic current problem

Two traversal sequences are known to construct binary trees
随机推荐
(Video + graphic) machine learning introduction series - Chapter 5 machine learning practice
士官类学校名录
XPT2046 四线电阻式触摸屏
怎样从微信返回的json字符串中截取某个key的值?
The task cannot be submitted after the installation of flick is completed
College entrance examination score line climbing
动态规划入门一,队列的bfs(70.121.279.200)
[leetcode] 344 reverse string
【LeetCode】876-链表的中间结点
目标检测—利用labelimg制作自己的深度学习目标检测数据集
Redux - detailed explanation
【LeetCode】1020-飞地的数量
Strings and arrays
使用 percona 工具给 MySQL 表加字段中断后该如何操作
Leetcode skimming -- sum of two integers 371 medium
matlab中wavedec2,说说wavedec2函数[通俗易懂]
Experiment collection of University "Fundamentals of circuit analysis". Experiment 4 - Research on linear circuit characteristics
6090. Minimax games
Redux——详解
[leetcode] 189 rotation array