SQL Server 数据插入,查询操作


建立数据库和表格[数据库的建立,基本表的建立,点击查看](https://blog.csdn.net/qq_50767141/article/details/115465639?spm=1001.2014.3001.5502)

数据插入

insert into <命名> values('XX','XX','XX',710);

数据查询

基本的查询子句

子句 含义
select 选择
from 来自
where / group by /order by 限制条件
having 和group by 一起使用
distinct 去除重复
between and 确定范围

数据查询

select * 
from student;

字符 ’*‘ 代表该表中所有的属性

select [dixtinct]<学号> 
from student;

字符 ’*‘ 代表该表中所有的属性去除重复的学号

select * 
from student
where class='01'

表示查询来自01班的所有学生信息

select * 
from student
where class='01'
group by<sex>

表示查询来自01班的所有学生信息并按照性别属性进行分组

select * 
from student
where class='01'
group by<sex>
having score between 90 and 100

表示查询来自01班的所有学生信息并按照性别属性进行分组要求成绩在90-100之间

select * 
from student
where class='01'
group by<sex>
order by<score>desc

表示查询来自01班的所有学生信息,按照性别属性进行分组并根据成绩属性进行降序排列


desc 降序 asc 升序

猜你喜欢

转载自blog.csdn.net/qq_50767141/article/details/117848839