title: Meaning of id = LAST_INSERT_ID(id)
body: <p>Supposing I have a table:</p>
  
  <pre><code>CREATE TABLE files (
      id_prod INT UNSIGNED NOT NULL DEFAULT PRIMARY KEY AUTO_INCREMENT,
      id_rel INT UNSIGNED,
      name VARCHAR(250),
      other VARCHAR(200),
      UNIQUE INDEX(id_rel , name)
  );
  </code></pre>
  
  <p>and I want to use an unique <code>query</code> to insert/update the data on this table:</p>
  
  <pre><code>INSERT INTO files (id_rel , name)
  VALUES ('25', 'test')
  ON DUPLICATE KEY UPDATE
  </code></pre>
  
  <p>now, reading the MySQL manual I read about this:</p>
  
  <pre><code>ON DUPLICATE KEY UPDATE id = LAST_INSERT_ID(id)
  </code></pre>
  
  <p>so I thought my query should be:</p>
  
  <pre><code>INSERT INTO files (id_rel , name)
  VALUES ('25', 'test')
  ON DUPLICATE KEY UPDATE id_prod = LAST_INSERT_ID(id), name = 'TESTED'
  </code></pre>
  
  <p>but which is the difference if I use only:</p>
  
  <pre><code>INSERT INTO files (id_rel , name)
  VALUES ('25', 'test')
  ON DUPLICATE KEY UPDATE name = 'TESTED'
  </code></pre>
  
  <p>?</p>
  
  <p>I cannot understand the meaning of LAST_INSERT_ID(id). What is (id) and what it's supposed to do?</p>