当前位置:网站首页>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 .FROM
After that, it is mainly connected with the data source , It can be single or multiple .WHERE
For conditional screening .GROUP BY
You can group the queried data according to the specified fields .HAVING
Used to filter groups , Is forGROUP BY
Separate groups for screening and so on .ORDER BY
Used to sort , Sort by a column ,ASC
It's in ascending order ,DESC
It's in descending order
版权声明
本文为[Jan York]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204232039375714.html
边栏推荐
- Bash script learning -- for loop traversal
- pikachuxss如何获取cookie靶场,返回首页总是失败
- LeetCode 232、用栈实现队列
- Go zero framework database avoidance Guide
- Resolve the eslint warning -- ignore the warning that there is no space between the method name and ()
- Latex formula
- Unity animation creates sequence frame code and generates animationclip
- Singleton mode
- The more you use the computer, the slower it will be? Recovery method of file accidental deletion
- 电脑越用越慢怎么办?文件误删除恢复方法
猜你喜欢
[SQL] string series 2: split a string into multiple lines according to specific characters
go defer
Some basic knowledge of devexpress report development
On BIM data redundancy theory
[PTA] get rid of singles
Leetcode 994, rotten orange
LeetCode 116. 填充每个节点的下一个右侧节点指针
GO語言開發天天生鮮項目第三天 案例-新聞發布系統二
High paid programmer & interview question series 91 limit 20000 loading is very slow. How to solve it? How to locate slow SQL?
MySQL基础之写表(创建表)
随机推荐
LeetCode 74、搜索二维矩阵
黑客的入侵方式你知道几种?
GO語言開發天天生鮮項目第三天 案例-新聞發布系統二
Leetcode 542, 01 matrix
Three. Based on ply format point cloud voxel model JS upload interface writing
LeetCode 20、有效的括号
I JS deep copy and shallow copy
Go limit depth traversal of files in directory
Parsing methods of JSON data in C - jar and jobobject: error reading jar from jsonreader Current JsonReader item
MySQL进阶之常用函数
Solve the Chinese garbled code of URL in JS - decoding
MySQL进阶之表的增删改查
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
Learn to C language fourth day
LeetCode 116. Populate the next right node pointer for each node
The more you use the computer, the slower it will be? Recovery method of file accidental deletion
[PTA] l1-006 continuity factor
bounding box iou
The problem of 1 pixel border on the mobile terminal
[PTA] l2-011 play with binary tree