单表查询
select column1,column2,...
from 表名
[where condition];
#从查询结果中去掉重复行
select distinct column1,column2...
from 表名
[where condition];
**
sql中特殊的比较运算符
**
1.expr1 between expr2 and expr3;
2.expr1 in (expr2,expr3,...);
3.like 字符串匹配,用来进行模糊查询
4.is null
#选出java_teacher>2并且student_id<2的记录
select * from student
where 2 between java_teacher and student_id;
#选出student_id等于2或4的所有记录
select * from student where student_id in(2,4);
#模糊查询。sql有两个通配符:_ 和 % 。_代表任意一个字符,%代表任意多个字
#符。
select * from student
where student_name like '孙_' and not student_id<5;
查询结果排序
# order by column1 [desc],column2...
select * from student where student_id>2
order by java_teacher desc,student_name;