I have a table like:
+----+------------+------------+
| id | expiry | timestamp |
+----+------------+------------+
| 1 | 2018-11-29 | 2018-11-01 |
| 2 | 2018-12-27 | 2018-11-01 |
| 3 | 2019-01-31 | 2018-11-01 |
| 4 | 2018-11-29 | 2018-11-01 |
| 5 | 2018-12-27 | 2018-11-01 |
+----+------------+------------+
How can I query all records for which expiry
is less than 30 days from timestamp
? ie
timestamp + 30 days > expiry
我建议:
where expiry < timestamp + interval 30 day
你可以试试这个
SELECT * FROM table_name WHERE DATE_ADD(TIMESTAMP , INTERVAL 30 DAY) > expiry;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.