MySql的DDL和DML和DQL的基本语法

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值