当前位置:网站首页>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
边栏推荐
- Jericho may have some chips with fast music playing speed [chapter]
- R语言构建回归模型诊断(正态性无效)、进行变量变换、使用car包中的powerTransform函数对目标变量进行Box-Cox变换(Box–Cox transform to normality)
- unity 等高线创建方法
- GO语言并发模型-MPG模型
- Kotlin shared mutable state and concurrency
- 如何解决 Iterative 半监督训练 在 ASR 训练中难以落地的问题丨RTC Dev Meetup
- **Puzzling little problem in unity - light and sky box
- 10_那些格调很高的个性签名
- Three efficient programming skills of go language
- pip uninstall all packages except builtin package
猜你喜欢
随机推荐
pip uninstall all packages except builtin package
10_那些格调很高的个性签名
MIT-6.824-lab4A-2022(万字讲解-代码构建)
【从零开始学zabbix】一丶Zabbix的介绍与部署Zabbix
15 differences between MES in process and discrete manufacturing enterprises (Part 2)
返回新列表
Rasa 3. X learning series - it is a great honor to be a source code contributor of Rasa contributors, and to build and share the rasa community with rasa source code contributors all over the world!
六石管理学:垃圾场效应:工作不管理,就会变成垃圾场
GO语言-init()函数-包初始化
puzzle(016.2)指画星河
Jerry's seamless looping [chapter]
SAP Marketing Cloud 功能概述(三)
js去除字符串空格
Record various sets of and or of mongotemplate once
Grendao usage problems
智源社区周刊#86:Gary Marcus谈大模型研究可借鉴的三个语言学因素;谷歌提出媲美Imgen的文生图模型Parti;OpenAI提出视频预训练模型VPT,可玩MC游戏
百度地图API绘制点及提示信息
P2pdb white paper
Defoaming
数据库注意事项









![Jerrys timer0 uses the default pa13 to detect the pulse width [chapter]](/img/4e/de0951c8be5ddd765b15b773c04fa7.png)