0

Hello i have got a table with logs in which i want to insert a new log only if 2 minutes have passed from the last record that was FR Type.

The table looks like this:

+-------+--------------------+------+
| ID    | update_time        | Type |
+-------+--------------------+------+
|  1    | 2015-11-12 17:05:09|  FR  |  
+-------+--------------------+------+
John Smith
  • 43
  • 1
  • 7
  • That's nice. Good luck figuring it out. Did you have a programming question? This site is for questions, not a place to dump your to-do lists. – Marc B Nov 16 '15 at 20:51
  • My question is: Is there any mysql query that could possible do this? – John Smith Nov 16 '15 at 20:53
  • not really. you can't modify a table that you're simultaneously selecting from. – Marc B Nov 16 '15 at 20:54
  • something like "INSERT INTO table IF SELECT update_time FROM table DESC LIMIT 1 > 2 MINUTES – John Smith Nov 16 '15 at 20:56
  • Check [this question](http://stackoverflow.com/questions/6854996/mysql-insert-if-custom-if-statements), which has pretty much the same problem. Also, Mysql has the _NOW()_ function, which you can use to get the difference in time. – Squirrel Nov 16 '15 at 21:08
  • Like I said, you cannot use a table as the target of an insert while simultaneously selecting from it. you'll have to do two separate queries. – Marc B Nov 16 '15 at 21:10

0 Answers0