鸽主姓名查询成绩_My SQL的简单查询学习

c8919e60f60f7102a0d70b4cca4e18fe.png

SQL简单查询学习,主要了解以下知识点:

  1. 基本查询语句;
  2. 定向查询条件;
  3. 注释和sql语句注意事项;
  4. 运算符:算术运算符、比较运算符和逻辑运算符;
  5. 字符串的模糊查询;

c94bfca851bc5f4010241a1b32ddd2eb.png

实操练习:

1、星号(*)——查询出全部列:

select * from student

b2a906ade2c7db96a2d619e1c2a32585.png

2、as——为列设定别名:

select 姓名 as s_name, 性别 as '人类行别' from student;

b3bed24a3294e75762aecb238885b7ba.png

3、distinct——删除重复项:

select distinct 姓名 from student;

02df56a321921e2cfe88ca82c089c656.png

4、where——指定查询条件:

select 姓名,学号 from student where 姓名='猴子';

d3acee14cee733bdc47ecb2c50f2de6d.png

5、运算符:

  • 算术运算符:
select 学号,成绩,成绩/100 as '百分比成绩' from score;

12f606cf02d04e59284d251675270fbd.png
  • 比较运算符:
select 学号,成绩 from score where not 成绩>=60;
select 学号,成绩 from score where 成绩<60;

6a08ce353991965ca8cdca9f5b415bd5.png
select 学号,成绩 from score where 成绩<60;

b40fa8e8689e66c54385b26609bfb3af.png
select 姓名,出生日期 from student where 出生日期<'1991-01-01';

25f2bb131c0151a7418d0d74c17a0844.png
  • 逻辑运算符:
select 学号,成绩 from score where 成绩>=60 and 成绩<=90;

0606c940192b1c4c05dc138c8afb93dc.png
select 姓名,性别 from student where 性别='男' and (姓名='猴子' or 姓名='马云');

4798110b37768555cbf7ea4869dce2e2.png
select 学号,成绩 from score where 成绩 between 60 and 90;
select学号,成绩 from score where 成绩>=60 and 成绩<=90;

6aa8da3dfae41c6774f6c8b7d2faa355.png
select 姓名,性别 from student where 姓名 in('猴子','马云');

94e0522797eb15bbe5c0621f86623406.png

6、查询null值

select 教师号,教师姓名 from teacher where 教师姓名 is null;

732cba203e71503edfb03bff91a077e2.png
select 教师号,教师姓名 from teacher where 教师姓名 is not null;

735fecff1c0a0c26ae9e02450caf99b9.png

7、模糊查询:

select * from student where 姓名 like '猴%';

4138e8702901e7c66ad064b62c07a1b0.png
select * from student where 姓名 like '%猴';

3bc746f1cb3865afb80cd4579ae44479.png
select * from student where 姓名 like '%猴%';

695b289dcc604f1a9f5485a65f58d8bc.png
select * from student where 姓名 like '王__';

d96171f2a5460639c90bbdabe2296b27.png

8、sqlzoo练习:

16d64872cb226a2d70cfe9ccedcf9c3f.png

fce89570a3ab8c36f36749a976caffb4.png

de5a71d2b04d171d05b8751b4c347a19.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值