mysql 查询语句

时间:2020-01-09 21:37:25   收藏:0   阅读:70

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%‘); 
 
技术分享图片

 

 技术分享图片

 

 



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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!