views:

29

answers:

2

Hi I was wondering if there was a simple solution in mysql to truncate mysql entries.

i.e.

if i want only a maximum of 100 entries in one table if a new entry is submitted, (101st entry) then it would delete lets say the last entry ( ordered by a time stamp ) and insert the new one (still only having 100 entries).

Any help much appreciated,

Regards, Phil

A: 

i do not think that is possible in mysql (http://forums.mysql.com/read.php?21,42315,175712#msg-175712).

create view on your table with limit 100 and order by date. (http://dev.mysql.com/doc/refman/5.5/en/create-view.html)

Haim Evgi
+1  A: 

You could solve the problem using triggers.

A trigger is a routine that is called when elements are inserted, deleted, or updated. So you could define a trigger that is run when a new element is inserted.

phimuemue