I would like to create a FIFO table in order to save only the most 50 recent infomations by deleting the oldest elements when a new infomation arrives. I can do it by manipulating ID in the table but I don’t think it is the best solution. Any idea of doing it well?
Share
You dont need to play with IDs in order to create a FIFO logic. The best would be to add another column as
DATETIMEin your table which automatically inserts current time-stamp that will help you to select records in ascending order with respect to this column. Your new column should be something like:Make sure when ever you insert new record, you must do a
COUNTcheck of total records in this table and if necessary delete the oldest record with respect to DateAdded. Moreover, you can make use ofLIMITand/orMAXin your select-query when it comes to delete the oldest record.