sql语句

 我们今天学习了sql server高级查询语句:

1.--select查询

Select *from student;

2.--all查询所有

Select all sex from student;

3.--Distinct 过滤重复

 Select distinct set from student;

4.--cont 统计

Select count (*) from  student;

Select count(sex) from  student;

Select count(distinct sex)from  student;

5.--top 取前条记录

Select top 3*from student;

6.--alias column name 列重命名

Select id as 编号,name’名称’,sex 性别 from student,

7.--Alias table name 表重命名

Select id ,name,s.id,s.name from student s;

8.-column 列运算

Select (age+id) col from stuent;

Select s.name+’-’+c.name from classes c,student s where s.cid=c.id;

       声明:此篇文档时来自于【狗刨学习网】社区-unity极致学院,是网友自行发布的Unity3D学习文章,如果有什么内容侵犯了你的相关权益,请与官方沟通,我们会即时处理。

9.--where 条件

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;

10.--and 并且

Select *from student where id>2 and sex =1;

11.--or 或者

Select*from studnt where id>2 and sex=1;

12.--beltween...and.....相当于并且

Select *from student where id between2 and 5;

Select *from student where id between2 and 5;

13.Like-模拟查询

Select *from student where name like %a%;

Select *from student where name like %[a][0]%;

Select* from studnt where name like %a%;

Select* ftom student where name like ja%;

14.--还学习了内连接查询语句

Select u.name,s.grade from score as s inner  join  users as u on s.uid=u.id

Select u.name,s grade from score as s inner  join  user as u on s.uid=u.id

15.--左外连接查询语句

Select u.name,s.grade from score as s inner  left  join users as u on s.uid=u.id

Select u name,s.grade from users as u inner  lest  join score as s on s.uid=u.id

16.--右外连接查询语句

select u.name,s.grade from score as s inner  right  join users as u on s.uid=uid

Select u name,s.grade from users as u inner  right  join score as s on s.uid=u.id

更多精彩:http://www.gopedu.com/article/category/dzsj

http://www.gopedu.com/article/category/dzsj

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值