当前位置:网站首页>Addition, deletion, modification and query of advanced MySQL data (DML)
Addition, deletion, modification and query of advanced MySQL data (DML)
2022-04-23 20:45:00 【Jan York】
increase
INSERT INTO stu(studentNo, loginPwd, studentName, sex, gradeId, phone, address, bornDate, mail, identityCard) VALUE ('123456','00000',' Jane ',' Secret ','1','1888888888',' Changsha ','2000-1-1','[email protected]','43032000000000');

INSERT INTO Table name ( Field 1, Field 2) VALUE ( value 1, value 2);
-- If not numerical , Please use single quotation marks , Such as :(' value 1',' value 2')
Insert multiple rows
INSERT INTO Table name ( Field 1, Field 2) VALUE ( value 1, value 2),( value 1, value 2);
-- This allows you to insert multiple lines at once
Insert the results of the query into a new table
Format 1
INSERT INTO Table name ( Field 1, Field 2) SELECT Field 1, Field 2 FROM Original table name ;
-- There is no need to say more about the use methods and problems that will arise , Try it yourself
Format 2
SELECT Field 1, Field 2 INTO The new name of the table FROM Original table name ;
Delete
-- DELETE FROM Table name WHERE [ Conditions ];
-- WHERE [ Conditions ] Don't write , Not writing is to unconditionally delete all , Conditional is to delete the qualified !!!
DELETE FROM stu WHERE studentNo = '888888';

Delete all data in the table
-- TRUNCATE TABLE Table name ;
TRUNCATE TABLE stu;
Be careful : Use this statement to delete data in the table , Will reset auto increment , And the execution efficiency is better than DELETE.
Change
UPDATE statement we use UPDATE key word .

-- UPDATE Table name SET Field name = ' field value ', Field name = ' field value ' WHERE [ Conditions ]
-- WHERE [ Conditions ] Don't write , Not writing is unconditionally modifying all , Conditional is to modify what meets the conditions !!!
UPDATE stu SET studentNo = '888888' WHERE studentNo = '123456';
check
SELECT * FROM stu WHERE studentNo = '888888';
This is a simple query statement . ditto ,WHERE It can be omitted , If not WHERE Conditions , Is to unconditionally query all .
We can also write more complex .
SELECT * FROM stu WHERE studentNo = '888888' GROUP BY studentNo ORDER BY studentNo ASC ;
We decompose , Take a look one by one .
notes :[ ] Inner represents an unnecessary statement .
SELECT * or < List of field names > FROM < Table name or view > [WHERE < Query criteria >] [GROUP BY Fields to be grouped ] [ORDER BY Fields to sort [ASC or DESC] ] ;
*Express all .FROMAfter that, it is mainly connected with the data source , It can be single or multiple .WHEREFor conditional screening .GROUP BYYou can group the queried data according to the specified fields .HAVINGUsed to filter groups , Is forGROUP BYSeparate groups for screening and so on .ORDER BYUsed to sort , Sort by a column ,ASCIt's in ascending order ,DESCIt's in descending order
版权声明
本文为[Jan York]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204232039375714.html
边栏推荐
- Learn to C language fourth day
- 高薪程序员&面试题精讲系列91之Limit 20000加载很慢怎么解决?如何定位慢SQL?
- Syntax Error: TypeError: this. getOptions is not a function
- Resolve the eslint warning -- ignore the warning that there is no space between the method name and ()
- [stack and queue topics] - sliding window
- 2021-09-02 unity project uses rider to build hot change project failure record of ilruntime
- Async function ------ ES6
- go slice
- LeetCode 74、搜索二维矩阵
- C# 知识
猜你喜欢

上海回应“面粉官网是非法网站”:疏于运维被“黑”,警方已立案

C migration project record: modify namespace and folder name

Shanghai responded that "flour official website is an illegal website": neglect of operation and maintenance has been "hacked", and the police have filed a case

Recommended usage scenarios and production tools for common 60 types of charts

"Meta function" of tidb 6.0: what is placement rules in SQL?

Come in and teach you how to solve the problem of port occupation

MySQL基础合集

JS arrow function user and processing method of converting arrow function into ordinary function

2021-09-02 unity project uses rider to build hot change project failure record of ilruntime

DOS command of Intranet penetration
随机推荐
Awk example skills
Leetcode 20. Valid parentheses
MySQL stored procedures and functions
Unity solves Z-fighting
Bracket matching -- [implementation of one-dimensional array]
三十一. `prototype`显示原型属性和`__proto__`隐式原型属性
Learn to C language fourth day
Install MySQL 5.0 under Linux 64bit 6 - the root password cannot be modified
內網滲透之DOS命令
Actual measurement of automatic ticket grabbing script of barley network based on selenium (the first part of the new year)
How to do after winning the new debt? Is it safe to open an account online
[PTA] l2-011 play with binary tree
LeetCode 994、腐烂的橘子
Go限制深度遍历目录下文件
Leetcode 1346. Check whether integers and their multiples exist
Leetcode 709, convert to lowercase
Communication between RING3 and ring0
Scrapy教程 - (2)寫一個簡單爬蟲
[stack and queue topics] - sliding window
The iswow64process function determines the number of program bits