I am trying to remove all results but the last 10 from a table. That shouldn’t be too hard, but they also have to match a certain criteria.
The table looks like this;
chat_id
location_id
user_id
message
created
Technically it has to remove everything with a specific location_id, and keep the last 10 records in the table.
Is this possible with the Active Record class?
THanks in advance
Not at all an optimal solution, but I guess this might help.
I’m assuming from your question that the criteria is a particular
location_id.If the created field is a timestamp field and by last 10 records, you mean the 10 most recent records, you can use a query similar to this: