存储过程代码: BEGIN IF sex_id =0 THEN SELECT COUNT(*) FROM mybatis.p_user WHERE p_user.sex='女' INTO sex_count; ELSE SELECT COUNT(*) FROM mybatis.p_user WHERE p_user.sex='男' INTO sex_count; END IF; END 条件: IN `sex_id` int,OUT `sex_count` int 执行: SET @sex_co…
SELECT HOUR(e.time) as Hour,count(*) as Count FROM error_log e WHERE e.date = '2017-09-02' GROUP BY HOUR(e.time) ORDER BY Hour(e.time); 下面是查询结果截图 在另一篇文章里,我总结了查询每半小时统计一次的方法.Mysql 查询一天中每半小时记录的数量…
SELECT HOUR(e.time)as Hour,FLOOR(MINUTE(e.time)/30) as M, COUNT(*) as Count FROM error_log e WHERE e.date = '2017-09-02' GROUP BY FLOOR(MINUTE(e.time)/30),HOUR(e.time) ORDER BY Hour(e.time); floor函数是mysql 的向下取整函数 如 floor(1.2) = 1 以下是运行结果: 要查看每小时统计,请看…
1. mysql查询所有表: SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '数据库名' AND TABLE_TYPE ='BASE TABLE' mysql查询建表语句: show create table `表名` 2.mysql查询所有视图: SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '数据库名'…
mysql查询中通配符的使用 在mysql查询中经常会使用通配符,并且mysql的通配符和pgsql的存在区别(稍候再讨论),而且mysql中还可以使用正则表达式. SQL模式匹配: “_” 匹配单个字符,”\_” 匹配”_” “%” 匹配任意个字符,包括零个字符 sql模式下的匹配,缺省是忽略大小写的,并且sql模式下的模糊匹配不能使用“=”或”!=”,而使用 like 或 not like. 例如: SELECT * FROM [user] WHERE u_name LIKE ‘%三…