美文网首页
常用查询语句

常用查询语句

作者: 成功的失败者 | 来源:发表于2020-06-17 17:04 被阅读0次
    1. 查询截止到每个月总开票量(使用了变量)
    select @count_m:=0;
    select t_time as '时间', @count_m:=total+@count_m as '开票量' from 
    (SELECT DATE_FORMAT(created_at,'%Y-%m') as t_time,count(*) as total FROM invoice  GROUP BY  t_time )  t group by t_time;
    
    1. 查看正在执行的事物,排查是否有数据被锁住
    SELECT * FROM information_schema.INNODB_TRX
    

    相关文章

      网友评论

          本文标题:常用查询语句

          本文链接:https://www.haomeiwen.com/subject/wtisxktx.html