I have a table that stores actions for rate-limiting purposes. What I want to do is fetch the newest row that has a 'key_action' (the action that starts the time for rate-limiting) and then find all entries after that date.
The only way I can currently think to do it is with two queries:
SELECT created_at FROM actions WHERE key_action=1 ORDER BY created_at DESC LIMIT 1
SELECT * FROM actions WHERE created_at >= (created_at from query 1)
Is there a was to combine these two queries into one?
You can make query 1 a subquery of query 2.