MySQL selects only new records

advertisements

How to write a MySQL query to achieve this task?

Table: writers

w_id    w_name
---------------
  1     Michael
  2     Samantha
  3     John
---------------

Table: articles

a_id   w_id   timestamp   a_name
----------------------------------------
  1      1    0000000001  PHP programming
  2      3    0000000003  Other programming languages
  3      3    0000000005  Another article
  4      2    0000000015  Web design
  5      1    0000000020  MySQL
----------------------------------------

Need to SELECT only those writers who published their first article not earlier than 0000000005.
(only writers who published at least one article can be selected)

In this example the result would be:

  2     Samantha

SQL code can be tested here http://sqlfiddle.com/#!2/7a308


Untested, but close:

SELECT w_id, MIN(timestamp) as min_time
from writers w
JOIN articles a on w.w_id = a.w_id
GROUP BY 1
HAVING min_time > 5