mysql 查询语句

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