Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A solution using good ol'-fashioned <code>LEFT JOIN</code> -- note in the example below, only the first row of BBB is inserted into AAA, because only it has no matching row in AAA. You'd replace <code>col1</code> and <code>col2</code> with the actual columns of the tables.</p> <pre><code>&gt; select * from AAA; +---------------------+------+------+ | timestamp | col1 | col2 | +---------------------+------+------+ | 2012-03-17 08:17:22 | 1 | 1 | | 2012-03-17 08:17:27 | 1 | 2 | | 2012-03-17 08:17:30 | 1 | 3 | | 2012-03-17 08:17:32 | 1 | 4 | | 2012-03-17 08:17:49 | 2 | 2 | | 2012-03-17 08:17:52 | 2 | 3 | | 2012-03-17 08:17:54 | 2 | 4 | +---------------------+------+------+ 7 rows in set (0.00 sec) &gt; select * from BBB; +---------------------+------+------+ | timestamp | col1 | col2 | +---------------------+------+------+ | 2012-03-17 08:18:16 | 2 | 1 | | 2012-03-17 08:18:18 | 2 | 2 | | 2012-03-17 08:18:20 | 2 | 3 | +---------------------+------+------+ 3 rows in set (0.00 sec) &gt; INSERT INTO AAA SELECT BBB.* FROM BBB LEFT JOIN AAA USING(col1,col2) WHERE AAA.timestamp IS NULL; &gt; select * from AAA; +---------------------+------+------+ | timestamp | col1 | col2 | +---------------------+------+------+ | 2012-03-17 08:17:22 | 1 | 1 | | 2012-03-17 08:17:27 | 1 | 2 | | 2012-03-17 08:17:30 | 1 | 3 | | 2012-03-17 08:17:32 | 1 | 4 | | 2012-03-17 08:17:49 | 2 | 2 | | 2012-03-17 08:17:52 | 2 | 3 | | 2012-03-17 08:17:54 | 2 | 4 | | 2012-03-17 08:18:16 | 2 | 1 | +---------------------+------+------+ 8 rows in set (0.00 sec) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload