title: Revert back to the previous version of a specific time in a temporal table of MariaDB
body: <p>I have a MariaDB temporal table as shown in below.</p>
  
  <p><strong>Schema</strong>:</p>
  
  <pre><code>MariaDB [teamdb]&gt; DESCRIBE t2;
  +-------+---------+------+-----+---------+---------------------------+
  | Field | Type    | Null | Key | Default | Extra                     |
  +-------+---------+------+-----+---------+---------------------------+
  | id    | int(11) | NO   | PRI | NULL    | auto_increment            |
  | x     | int(11) | YES  |     | NULL    |                           |
  | y     | int(11) | YES  |     | NULL    | WITHOUT SYSTEM VERSIONING |
  +-------+---------+------+-----+---------+---------------------------+
  </code></pre>
  
  <p><strong>Data (Current)</strong>:</p>
  
  <pre><code>MariaDB [teamdb]&gt; SELECT * FROM t2;
  +----+------+------+
  | id | x    | y    |
  +----+------+------+
  |  1 |    1 |    1 |
  |  2 |    2 |    2 |
  |  3 |    3 |    4 |
  |  4 |    5 |    4 |
  +----+------+------+
  </code></pre>
  
  <p><strong>Data (with History)</strong>:</p>
  
  <pre><code>MariaDB [teamdb]&gt; select *, ROW_START, ROW_END from t2 FOR SYSTEM_TIME ALL;
  +----+------+------+----------------------------+----------------------------+
  | id | x    | y    | ROW_START                  | ROW_END                    |
  +----+------+------+----------------------------+----------------------------+
  |  1 |    1 |    1 | 2019-08-15 06:41:18.684508 | 2038-01-19 03:14:07.999999 |
  |  2 |    1 |    2 | 2019-08-15 06:41:18.684508 | 2019-08-15 06:42:11.661167 |
  |  2 |    2 |    2 | 2019-08-15 06:42:11.661167 | 2038-01-19 03:14:07.999999 |
  |  3 |    3 |    4 | 2019-08-15 06:41:18.684508 | 2038-01-19 03:14:07.999999 |
  |  4 |    5 |    4 | 2019-08-15 06:41:18.684508 | 2038-01-19 03:14:07.999999 |
  +----+------+------+----------------------------+----------------------------+
  </code></pre>
  
  <p><strong>Question:</strong>
  I wanted to revert back the record (<code>id=2</code>) to the version which was in <code>2019-08-15 06:42:10.661167</code> timestamp. That means, after the update, record #2 should have <code>x = 1</code> again.</p>
  
  <p>I tried inserting with <code>ON DUPLICATE</code> as shown in below query,</p>
  
  <pre><code>INSERT INTO t2 (id,x,y) 
    SELECT t.id,t.x,t.y 
    FROM t2 t 
    FOR SYSTEM_TIME AS OF TIMESTAMP '2019-08-15 06:42:10.661167' 
    WHERE t.id=2 
  ON DUPLICATE KEY UPDATE x=t.x, y=t.y;
  </code></pre>
  
  <p>This gave me the error saying there is a syntax error.</p>
  
  <pre><code>ERROR 1064 (42000): You have an error in your SQL syntax; 
  check the manual that corresponds to your MariaDB server version 
  for the right syntax to use near 'SYSTEM_TIME AS OF TIMESTAMP '2019-08-15 06:42:10.661167' WHERE t.id=2 ON DUPLICA' at line 1
  </code></pre>
  
  <p>According to the error, it seems MariaDB does not identify <code>FOR</code> clause in select inserts.</p>
  
  <p>Any other way to revert back to the other version using a query.</p>