zoukankan      html  css  js  c++  java
  • sql随笔

    sql随笔

    查询当日

    select '字段’ from '表名'
    where to_days('日期字段') = to_days(now())

    查询当月

    SELECT * FROM '表名'
    WHERE DATE_FORMAT( '日期字段', '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m')

    查询排序名次

    select * from(select id,name,mingci,(@ranknum:= @ranknum+ 1) as rownum(虚拟排序字段) from 表名,(select(@ranknum := 0))b (表别名)
    where '内条件' order by 排序的字段 desc) 表名
    where '外条件'

    最近月

    SELECT DATE_FORMAT(CURDATE(), '%Y-%m') AS year_month
    UNION SELECT DATE_FORMAT((CURDATE() - INTERVAL 1 MONTH), '%Y-%m') AS year_month
    UNION SELECT DATE_FORMAT((CURDATE() - INTERVAL 2 MONTH), '%Y-%m') AS year_month
    UNION SELECT DATE_FORMAT((CURDATE() - INTERVAL 3 MONTH), '%Y-%m') AS year_month
    UNION SELECT DATE_FORMAT((CURDATE() - INTERVAL 4 MONTH), '%Y-%m') AS year_month
    UNION SELECT DATE_FORMAT((CURDATE() - INTERVAL 5 MONTH), '%Y-%m') AS year_month

  • 相关阅读:
    Jenkins 搭建篇
    gitlab搭建使用
    apiDoc部署搭建
    传统切图
    Web前端性能优化的9大问题
    photoshop cc 智能切图
    ps切图
    前端ps切图,图文教程,详细。
    axios
    数组API
  • 原文地址:https://www.cnblogs.com/yu-si/p/12753878.html
Copyright © 2011-2022 走看看