LoginSignup
0
0

More than 3 years have passed since last update.

mysql 過去180日のデータ取得

Posted at

日付を計算する場合

SELECT * FROM summary_tags
WHERE created_at BETWEEN (CURDATE() - INTERVAL 180 DAY) AND (CURDATE() + INTERVAL 1 DAY)
AND tag_id = 1473

interval xx dayは日付を表す
whereの条件はandで繋いでいく

日付を直接指定する場合

SELECT * FROM summary_tags
WHERE created_at >= '2018-12-03 03:00:07'
AND tag_id = 1473

テーブル名、カラム名はただの事例
以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0