随笔分类 -  数据库

摘要:查询某个字段以某个字母开头的数据 模糊查询:select * from table_name where col_name like 'Y%'; select * from table_name where col_name like 'Y_'; 其中'_'代表只能有一个字符 select * fr 阅读全文
posted @ 2020-04-07 20:01 忆梦,惊梦 阅读(284) 评论(0) 推荐(0)
摘要:子查询子查询是指出现在其他SQL语句内的SELECT子句。例如:select * from t1 where col1=(select col2 from t2);其中select col2 from t2,称为子查询子查询的外层查询可以是:select,insert,update,set或do。使 阅读全文
posted @ 2020-03-24 22:24 忆梦,惊梦 阅读(186) 评论(0) 推荐(0)
摘要:group by查询结果分组[GROUP BY {col_name|position} [ASC|DESC],...]SELECT class from tb1 GROUP BY class; 例如:统计每个班级中每种性别的学生人数,并按照班级升序排序 select class,sex,count( 阅读全文
posted @ 2020-03-24 20:23 忆梦,惊梦 阅读(305) 评论(0) 推荐(0)
摘要:创建数据表: CREATE TABLE if not EXISTS table_name( colunm_name data_type, ...) CREATE TABLE tb1( username VARCHAR(20), age TINYINT UNSIGNED, #unsigned类型,即无 阅读全文
posted @ 2020-03-24 17:18 忆梦,惊梦 阅读(180) 评论(0) 推荐(0)