› MySQL 5.5 Community Server
› MySQL 5.6 Community Server
› Percona Configuration Wizard
› XtraBackup 搭建主从复制
Great Sites on MySQL
› Percona
› MySQL Performance Blog
› Severalnines
推荐管理工具
› Sequel Pro
› phpMyAdmin
推荐书目
› MySQL Cookbook
MySQL 相关项目
› MariaDB
› Drizzle
参考文档
› http://mysql-python.sourceforge.net/MySQLdb.html
cnmllll
V2EX  ›  MySQL

MySQl,获取当前日期后三十天以内的数据

  •  
  •   cnmllll · May 12, 2020 · 2885 views
    This topic created in 2334 days ago, the information mentioned may be changed or developed.

    SELECT PRE_OPERATE_DATE FROM fj_con_electricalprojec_b WHERE PRE_OPERATE_DATE BETWEEN DATE_SUB(NOW(), INTERVAL - 30 DAY);

    语句报错是怎么回事? [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 6

    求解其他查询方法~

    4 replies  •  2020-05-12 14:28:21 +08:00
    pushback
        1
    pushback  
       May 12, 2020
    BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) and DATE_ADD(NOW(), INTERVAL 30 DAY)
    pushback
        2
    pushback  
       May 12, 2020
    差个 and,吧 and 前后换成你想要的日期就行了,选个函数
    cnmllll
        3
    cnmllll  
    OP
       May 12, 2020
    @pushback ~我只获取当前日期后三十天数据该怎么改呢
    pushback
        4
    pushback  
       May 12, 2020
    @cnmllll 你把 and 前面换成 NOW()不就行了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2299 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 10:09 · PVG 18:09 · LAX 03:09 · JFK 06:09
    ♥ Do have faith in what you're doing.