Mysql笔记【4】-查询操作
1、查询所有列数据 select * from 表名 一般情况下,除非使用表中所有字段,最好不要使用通配符 "*",如果不知道所需要的列名,可以使用*查询获取 2、带in关键字的查询 select * from 表名 where 列 in (条件1,条件2) 3、带between and的范围查询 select * from 表明 where 列 between 范围1 and 范围2 4、模糊查询 like % 匹配任意字符 —匹配任意单个字符 5、查询空值 is null select * from 表名 where 列 is [not] null 6、and的多条件查询 select * from 表名 where 列1=条件1 and 列2=条件2 7、or的多条件查询 select * from 表名 where 列1=条件1 or 列2=条件2 8、distinct的不重复查询 select distinct 列 from 表名 [where 条件] 9、【单列/多列】排序 order by 列1[列2...] [asc默认升序/desc降序] 在多列进行排序的时候,首先排序第一列,想通了再比较第二列,一次类似 10、分组 group by 【having 条件】 * having是分组之后进行过滤分组的 * where条件是分组之前进行过滤