当前位置:网站首页>MySql的DDL和DML和DQL的基本语法
MySql的DDL和DML和DQL的基本语法
2022-07-24 03:17:00 【随性.533】
SQL 中最重要的 DDL 语句:
CREATE DATABASE - 创建新数据库
ALTER DATABASE - 修改数据库
CREATE TABLE - 创建新表
ALTER TABLE - 变更(改变)数据库表
DROP TABLE - 删除表
CREATE INDEX - 创建索引(搜索键)
DROP INDEX - 删除索引

SQL语句的DML 部分:
SELECT - 从数据库表中获取数据
UPDATE - 更新数据库表中的数据
DELETE - 从数据库表中删除数据
INSERT INTO - 向数据库表中插入数据

SQL的DQL的基本语法
| select+字段列表 | 基本查询 |
| from+表名列表 | 基本查询 |
| where+条件列表 | 条件查询 |
| group by+分组字段列表 | 分组查询 |
| having+分组后条件列表 | 分组查询 |
| order by+排序字段列表 | 排序查询 |
| limt+分页参数 | 分页查询 |

-- 分页
select *from student limit 2,3; -- 公式 (页码-1)*步长 -- 外联查询
-- left join on 左外联
-- right join on 右外联
select *from student left join class on student.classid= class.classid;-- 左外联
union
select *from student right join class on student.classid=class.classid; -- 右外联
use myschool;
group by 分组
select student.sid,sname,avg(score) a from student,sc where student.sid=sc.sid
group by sid having a>=60
like % 模糊查询
select count(*) from teacher where tname like '李%'
desc 降序
检索” 01 “课程分数小于 60,按分数降序排列的学生信息
select * from sc left join student on sc.sid = student.sid where score < 60 and cid = 1 order by score desc
边栏推荐
- The process of solving a bug at work
- Lcd1602——斌哥51
- The implementation in unity determines whether missing or null
- 在openEuler社区开源的Embedded SIG,来聊聊它的多 OS 混合部署框架
- Gpushare. COM | how to use tensorboardx visualization tool?
- FTP服務與配置
- 关于Aries框架增删改查-查Demo
- Microsoft win11/10 package manager Winget will support the installation of applications from zip files
- 错误代码0x80004005
- IDEA Clone的项目报Cannot resolve symbol ‘Override‘
猜你喜欢

Lcd1602——斌哥51

Xiaodi and Xiaohui

An introductory example of structure and combinatorial ideas in go language

C user defined type details

Ue5 split screen (small map) solution

Error code 0x80004005

Summernote rich text editor

微信公众号在线客服接入发方法和功能详解

Microsoft win11/10 package manager Winget will support the installation of applications from zip files

C file operation details
随机推荐
Expressions régulières \ \ B \ \ b compréhension de l'appariement des limites des mots
How does the small program mall refine the operation of members?
C文件操作详解
Unity message push
Ugui source code analysis - maskablegraphic
Bingbing learning notes: basic operation of vim tool
正则表达式 \b \B 深入浅出理解单词边界的匹配
JIRA automation experience sharing for 2 years
[C language] file operation
go strconv
The implementation in unity determines whether missing or null
uva1445
Basic use of Pinia
JVM初始
JVM初始
TCP connection principle
WPS前骨干历时10年打造新型软件,Excel用户:我为此改用WPS
FTP服务与配置
Xiaodi and Xiaohui
Summernote rich text editor