首页 > 数据库技术 > 详细

mysql 查询语句

时间:2020-01-09 21:37:25      阅读:70      评论:0      收藏:0      [点我收藏+]

1.//一个sql返回多个总数 统计数据

select count(*) AS num,count(case when status = 1 then status end) as status_1_num,count(case when status = 0 then status end) as status_0_num from ws_users;

技术分享图片

 

 2.时间戳查询转换

 select id, from_unixtime(time_line, ‘%Y-%m-%d %h:%i:%s‘) as day  from ws_chat_log where id >10;

技术分享图片

 

 

3.替换某字段的内容的语句
数据库中有aaa的文字换成 bbb
update ws_users set user_name = REPLACE(user_name, ‘李志刚2‘, ‘李志刚3‘)  where (user_name like ‘%李志刚2%‘); 
 
技术分享图片

 

 技术分享图片

 

 



mysql 查询语句

原文:https://www.cnblogs.com/kevin-yang123/p/12172800.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!