您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

MYSQL很好的SQL语句_MySQL

2025/10/25 19:08:11发布25次查看
bitscn.com
mysql很好的sql语句
mysql-
1.将查询结果中的0/1分别显示女/男select case sexwhen 1 then '男'when 0 then '女'else '不确定'endfrom carsystem.user2.删除表的一列alter table test_user drop column age3.只更新当天登陆的民警的退出时间update policemenlogin set quitdate=now() where policemenid='p4' and to_days(logindate)8to_days(now())4.查过去24小时之内的数据(一下内容参见另一篇文章:2013.10.13 事务特性、mysql 触发器、存储过程、函数)核心:checkdate >date_add(now(), interval -1 day)string sql = select * from records where vehicleid=' + vehicleid+ ' and checkdate >date_add(now(), interval -1 day)+ order by checkdate desc;date_add(now(),interval -1 day);系统函数,指当前时间减去1天,即过去24小时时间段内5.按天数统计数据数量select count(*),records.checkdate from records group by to_days(records.checkdate);6.按月份统计数据数量select count(*),records.checkdate from records group by month(records.checkdate);7.获取当天数据select * from policemenlogin where date_format(logindate,'%y-%m-%d')=curdate();//取当天数据8.按月份分组select date_format(time,'%y%m') t,count(*) '数量' from `user` group by period_diff( t,'200001');period_diff( t,'200001');//返回2000年01月到t时间的总月份数
bitscn.com
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product