数据库查询汇总
其他
2019-04-13 22:11:27
阅读次数: 0
-
- 转载
- 原文地址:http://blog.csdn.net/liuxinmingcode/article/details/51554061
-
-
-
-
-
-
select all sex from student;
-
-
-
select distinct sex from student;
-
-
-
select count(*) from student;
-
select count(sex) from student;
-
select count(distinct sex) from student;
-
-
-
select top 3 * from student;
-
-
-
select id as 编号, name ‘名称’, sex 性别 from student;
-
-
-
select id, name, s.id, s.name from student s;
-
-
-
select (age + id) col from student;
-
select s.name + ‘-’ + c.name from classes c, student s where s.cid = c.id;
-
-
-
select * from student where id = 2;
-
select * from student where id > 7;
-
select * from student where id < 3;
-
select * from student where id <> 3;
-
select * from student where id >= 3;
-
select * from student where id <= 5;
-
select * from student where id !> 3;
-
select * from student where id !< 5;
-
-
-
select * from student where id > 2 and sex = 1;
-
-
-
select * from student where id = 2 or sex = 1;
-
-
-
select * from student where id between 2 and 5;
-
select * from student where id not between 2 and 5;
-
-
-
select * from student where name like ‘%a%’;
-
select * from student where name like ‘%[a][o]%’;
-
select * from student where name not like ‘%a%’;
-
select * from student where name like ‘ja%’;
-
select * from student where name not like ‘%[j,n]%’;
-
select * from student where name like ‘%[j,n,a]%’;
-
select * from student where name like ‘%[^ja,as,on]%’;
-
select * from student where name like ‘%[ja_on]%’;
-
-
-
select * from student where id in (1, 2);
-
-
-
select * from student where id not in (1, 2);
-
-
-
select * from student where age is null;
-
-
-
select * from student where age is not null;
-
-
-
select * from student order by name;
-
select * from student order by name desc;
-
select * from student order by name asc;
-
-
-
-
select count(age), age from student group by age;
-
-
select count(*), sex from student group by sex;
-
-
select count(*), sex from student group by sex, age order by age;
-
按照性别分组,并且是id大于2的记录最后按照性别排序
-
select count(*), sex from student where id > 2 group by sex order by sex;
-
查询id大于2的数据,并完成运算后的结果进行分组和排序
-
select count(), (sex id) new from student where id > 2 group by sex * id order by sex * id;
-
-
-
-
select count(*), age from student group by all age;
-
-
-
按照年龄分组,过滤年龄为空的数据,并且统计分组的条数和现实年龄信息
-
select count(*), age from student group by age having age is not null;
转载自www.cnblogs.com/woyaozilv/p/10703088.html