MySQL Where date is greater than one month?

前端 未结 3 2024
南笙
南笙 2021-01-17 10:24

I have a datetime column called \'last_login\'.

I want to query my database to select all records that haven\'t logged in within the last month. How do I do this?

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-17 11:14

    matthewh was almost correct, except the > should have been a right one.

    where u.last_login > date_sub(now(), interval 1 month)

提交回复
热议问题