1)order by
--以字母顺序排序数据,默认是升序
select column1 from table order by column1;
--按照多个列进行排序
select column1, column2, column3, column4 from table order by column1, column2;
2)desc
desc关键字只应用到直接位于它前面的列名;
如果想对多个列进行降序排序,必须对每个列指定desc关键字;
与desc相反的是asc,但是order by默认就是升序的。
--根据column1 降序排序
select column1 from table order by column1 desc
--结合limit选择出最大值
select column1 from table order by column1 desc limit 1;
3)where
不等于的两种表示方式:!= 和 <>;
在指定的两个值之间:between a and b,包括开始值a和结束值b在内;
4)is null
--空值检查:在一个列不包含值时,称其为包含空值null
select column1 from table where column2 is null;
5)like
select column1 from table where column2 like '%要匹配的关键字%';
通配符:%——匹配多个字符;下划线_——匹配单个字符