立即学习:https://edu.csdn.net/course/play/29528/420883?utm_source=blogtoedu
select * from 表名;查看表内所有数据
selcet 字段1,字段2 from 表名;查看指定字段
比较条件查询:select * from 表名 where 条件;例:1、select password from user3 where username='王伟';2、select * from user3 where createDatetime is not null; 3、select createDatetime from user3 where id>=5;
模糊查询:select * from 表名 where 字段1 like '表达式';(%:匹配任意多的字符);( _ :匹配一个字符);例:1、select * from user3 where username like '%秀%'; 2、select * from user3 where username like '王_';
范围查询:select * from 表名 where 字段 in (可能1,可能2);例:select * from user3 where username in ('王伟','李娜');或者 select * from user3 where username='王伟' or username='李娜' ;
分组:
1、select * from 表名 where 条件 group by 字段1,字段2;例:对user3中的createDatetime进行分组,统计每一个存在的createDatetime对应的数据条数;select count(*),createDatetime from user3 group by createDatetime;
2、select * from 表名 where 条件 group by 字段1,字段2 having 条件;(说明:where 是对select * from 的结果进行筛选,having是对group by 的最后结果进行筛选);