当前位置:网站首页>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
边栏推荐
- go reflect
- Come in and teach you how to solve the problem of port occupation
- The more you use the computer, the slower it will be? Recovery method of file accidental deletion
- 【栈和队列专题】—— 滑动窗口
- 100天拿下11K,转岗测试的超全学习指南
- Psychological formula for converting RGB to gray value
- Imitation Baidu map realizes the three buttons to switch the map mode by automatically shrinking the bottom
- Vulnhub DC: 1 penetration notes
- 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
- 内网渗透之DOS命令
猜你喜欢

Another data analysis artifact: Polaris is really powerful

MySQL数据库常识之储存引擎

The construction and use of Fortress machine and springboard machine jumpserver are detailed in pictures and texts

Identifier CV is not defined in opencv4_ CAP_ PROP_ FPS; CV_ CAP_ PROP_ FRAME_ COUNT; CV_ CAP_ PROP_ POS_ Frames problem

Install MySQL 5.0 under Linux 64bit 6 - the root password cannot be modified

What about laptop Caton? Teach you to reinstall the system with one click to "revive" the computer

Shanghai a répondu que « le site officiel de la farine est illégal »: l'exploitation et l'entretien négligents ont été « noirs » et la police a déposé une plainte

Preliminary understanding of cache elimination algorithm (LRU and LFU)

Latex formula

UnhandledPromiseRejectionwarning:CastError: Cast to ObjectId failed for value
随机推荐
[PTA] l1-002 printing hourglass
Leetcode 232, queue with stack
Some basic knowledge of devexpress report development
vulnhub DC:1渗透笔记
Bracket matching -- [implementation of one-dimensional array]
Use of node template engine
Recommended usage scenarios and production tools for common 60 types of charts
LeetCode 542、01 矩阵
启牛学堂有用吗,推荐的证券账户是否安全
[PTA] l2-011 play with binary tree
pikachuxss如何获取cookie靶场,返回首页总是失败
Go限制深度遍历目录下文件
3-5 obtaining cookies through XSS and the use of XSS background management system
The iswow64process function determines the number of program bits
Communication between RING3 and ring0
41. 缺失的第一个正数
UKFslam
Introduction to standardization, regularization and normalization
MySQL进阶之常用函数
Unity ECS dots notes