 <p>Not a very clear question but you can use a query like this: (<strong>untested</strong>)</p> <pre><code>insert into pageview select 15, 'A VISITOR', 10, now() from pageview a where id_realestate=10 and DATE_ADD(now(),INTERVAL -30 MINUTE) &gt; ( select max(news_release) from pageview b where a.id_realestate=b.id_realestate ); </code></pre>