一、SQL基本查询语句
1、从表中查询2列
select 姓名,性别
from student;
2、查询出全部列
select *
from student;
3、为列赋予别名
select 姓名 as s_name,性别 as '人类性别'
from student;
4、删除重复数据
①删除某列重复数据
select distinct 姓名
from student;
②删除两列的重复数据
select distinct 学号,姓名
from student;
5、SQL查询语句书写规则

二、条件查询
1、SQL查询语句的运行顺序
select 学号,姓名
from student
where 姓名='猴子';


2、注释

3、SQL查询语句注意事项

4、运算符
①算术运算符

select 学号,成绩,成绩/100 as '百分比成绩'
from score;
②比较运算符和逻辑运算符


❶not用法

❷and和between的用法

❸and和or的用法

select 姓名,性别
from student
where 性别='男' and (姓名='猴子' or 姓名='马云');
❹not in 的用法

❺字符串比较、如何查询出null值
ⅰ、字符串比较规则:
'10'<'2'ⅱ、如何查询出null值
select 教师号,教师姓名
from teacher
where 教师姓名 is null;select 教师号,教师姓名
from teacher
where 教师姓名 is not null;
5、字符串模糊查询




三、SQLZOO:SELECT from world











本文介绍了SQL的基本查询语句,包括从表中选择特定列、选择所有列、删除重复数据等操作,并提供了条件查询的示例,如使用算术运算符、比较运算符和逻辑运算符进行复杂查询。

被折叠的 条评论
为什么被折叠?



