查找时间字符串大于当前时间SQL的行

I have a column within a table that is used to track when something was deleted. All it holds is a timestamp via the php time() function. I now need to find those rows that contain a timestamp created 90 days ago or more. I'm having trouble with this query.

This is what I thought would work

SELECT * FROM `table` WHERE (table.deleted + (90 * 24 * 60 * 60)) >= CURRENT_TIMESTAMP

What about using intervals?

... WHERE table.deleted < (now() - interval 90 DAY)

This will fetch all the records whose table.deleted value is older than 90 days.

You've got the operator to the wrong side. You want files deleted more than 90 days ago so:

SELECT * FROM `table` WHERE (table.deleted + (90 * 24 * 60 * 60)) <= CURRENT_TIMESTAMP;
SELECT * FROM list WHERE unix_timestamp()-lastrequest>7776000

The above example requires:

  1. Your timestamps in the row must be in unix_timestamp() format (you can create unix timestamps from at least bash, php and mysql)
  2. Replacement of "lastrequest" with your row's name

You actually subtract current timestamp (unix_timestamp() in MySQL) from your row's content and check if the difference is bigger than 7776000 (which means 90 days)

Hope it helps.