当前位置:网站首页>MySQL title
MySQL title
2022-06-24 14:19:00 【CV Engineer】
1. increase
1.1 Add data for the specified field in the table
INSERT INTO Table name ( Field name 1, Field name 2,…)VALUES( value 1, value 2,…)
INSERT INTO `user`(id,role) VALUES(3,"admin");
1.2 Add data for all fields in the table ( Can not specify a field )
INSERT INTO Table name VALUES( value 11, value 2,…);
INSERT INTO `user` VALUES(5,"lsy","lsy1234","admin");
1.3 Add multiple pieces of data at the same time
INSERT INTO `user` VALUES(6,"lsy","lsy1234","admin"),
(7,"lsy7","lsy1234","admin"),
(8,"lsy8","lsy1234","admin");
2. Delete
2.1 Delete some data
DELETE from user where username="lsy"
2.2 Delete all data
DELETE from user
3. Change
3.1 Modify some data
UPDATE user set role="admin1" where id=9
3.2 Modify all data
UPDATE user set role="admin2"
4. check
4.1 Simple query
select id,role from user
select * from user
select id,role from user where id<10
select id,role from user where id in (9,10)
select id,role from user where id BETWEEN 2 and 10
select id,role from user where role is NULL
select id,role from user where role like "adm%"(% Match any length of string , Include empty string .)
select id,role from user where role like "adm_"( The underscore wildcard matches only a single character )
select id,role from user where role like "admi_" and username="shiro"(AND Has a higher priority than OR)
select id,role from user where role like "admi_" or username="shiro"
4.2 Advanced query
SELECT COUNT(*) FROM user
SELECT sum(id) FROM user
SELECT avg(id) FROM user
SELECT max(id) FROM user
SELECT min(id) FROM user
SELECT *from user order by id DESC
SELECT COUNT(*) ,gender FROM user GROUP BY gender;
SELECT sum(grade),gender FROM user GROUP BY gender HAVING SUM(grade) < 300;
SELECT * from user LIMIT 2
4.3 Subquery
SELECT * FROM user where id=(SELECT MAX(id) from user)
SELECT * FROM (SELECT MAX(id) from user) as user1
4.4 Table joins
SELECT * FROM user u INNER JOIN role r on u.id=r.id
SELECT * FROM user u LEFT JOIN role r on u.id=r.id
SELECT * FROM user u RIGHT JOIN role r on u.id=r.id
SELECT * FROM user u LEFT JOIN role r on u.id=r.id UNION SELECT * FROM user u RIGHT JOIN role r on u.id=r.id
边栏推荐
猜你喜欢

【LeetCode】10、正则表达式匹配

文本对比学习综述
![Jerrys timer0 uses the default pa13 to detect the pulse width [chapter]](/img/4e/de0951c8be5ddd765b15b773c04fa7.png)
Jerrys timer0 uses the default pa13 to detect the pulse width [chapter]

tongweb使用之端口冲突处理办法

IDEA连接mysql自定义生成实体类代码

Unit contour creation method

PgSQL queries the largest or smallest data of a field in a group

P2pdb white paper

Baidu map API drawing points and tips

从谭浩强《C程序设计》上摘录的ASCII码表(常用字符与ASCII代码对照表)
随机推荐
Idea connection MySQL custom generated entity class code
Unit contour creation method
v-for 中 key的作用和原理
Jerry's seamless looping [chapter]
A review of text contrastive learning
Defeat the binary tree!
在CVS中恢复到早期版本
4个不可不知的“安全左移”的理由
【比特熊故事汇】6月MVP英雄故事|技术实践碰撞境界思维
常见的单例模式&简单工厂
文本对比学习综述
数商云:加强供应商管理,助推航空运输企业与供应商高效协同
Method of inputting dots under letters in markdown/latex
成功解决:selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This versi
一文搞定 UDP 和 TCP 高频面试题!
Linux 安装 CenOS7 MySQL - 8.0.26
Baidu map API drawing points and tips
P2PDB 白皮书
远程办公之:在家露营办公小工具| 社区征文
Jericho may have some chips with fast music playing speed [chapter]