当前位置:网站首页>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] 200 number of islands
- PyObject 转 char* (string)
- 2278. 字母在字符串中的百分比
- [leetcode] 1254 - count the number of closed Islands
- 将点云坐标转换成世界坐标的demo
- Pyinstaller打包exe附带图片的方法
- [leetcode] 167 - sum of two numbers II - enter an ordered array
- Leetcode skimming - remove duplicate letters 316 medium
- Fiddler实现手机抓包——入门
猜你喜欢

Finally, I understand the event loop, synchronous / asynchronous, micro task / macro task, and operation mechanism in JS (with test questions attached)

Experiment collection of University "Fundamentals of circuit analysis". Experiment 4 - Research on linear circuit characteristics

How to intercept the value of a key from the JSON string returned by wechat?

PTA ladder game exercise set l2-001 inter city emergency rescue

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

03. Preliminary use of golang

【LeetCode】1254-统计封闭岛屿的数量

Soul torture, what is AQS???

Experiment collection of University "Fundamentals of circuit analysis". Experiment 6 - observation and measurement of typical signals

密码学基础知识
随机推荐
Moveit obstacle avoidance path planning demo
Pyobject to char* (string)
[network security] network asset collection
lseek 出错
Digital collection system development (program development) - Digital Collection 3D modeling economic model system development source code
已知两种遍历序列构造二叉树
[leetcode] 19 delete the penultimate node of the linked list
Comparison between rstan Bayesian regression model and standard linear regression model of R language MCMC
【LeetCode】977-有序数组的平方
The outline dimension function application of small motherboard
Ant group's large-scale map computing system tugraph passed the national evaluation
[leetcode] 167 - sum of two numbers II - enter an ordered array
Moveit 避障路径规划 demo
03. Preliminary use of golang
[leetcode] 417 - Pacific Atlantic current problem
2303. Calculate the total tax payable
02. After containerization, you must face golang
Add an empty column to spark dataframe - add an empty column to spark dataframe
/bin/ld: 找不到 -lssl
[leetcode] 189 rotation array