title: How to get original insert statement from database
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3978326/get-insert-statement-for-existing-row-in-mysql">Get Insert Statement for existing row in MySQL</a>  </p>
  </blockquote>
  
  
  
  <p>Lets say we have a table called users: </p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS users(
  UID int(11) PRIMARY KEY NOT NULL auto_increment,
  fname varchar(100) default NULL,
  lname varchar(100) default NULL,
  username varchar(20) default NULL UNIQUE,
  password blob   
  )ENGINE=InnoDB DEFAULT CHARSET=utf8
  </code></pre>
  
  <p>Lets assume there's a few rows filled up in the table. 
  I know there is a query that returns the creation of the table -> SHOW CREATE TABLE users
  But I'm looking to recreate individual insert statements to save them in a log...I know this sounds weird, but I am making a custom CMS where everything is logged, and hopefully where updated/deleted rows could rollback at point in time...therefore I would need to recreate exact insertion query from table data (I have searched all over the web for an answer and can't find it...)</p>
  
  <p>Is there a query that would return "automatically" the query that inserted that specific row by primary key?</p>
  
  <p>I am looking for a query that would do this:</p>
  
  <pre><code>SHOW INSERT FROM users WHERE PRIMARY_KEY=2
  </code></pre>
  
  <p>Returns:</p>
  
  <pre><code>INSERT INTO users (UID,fname,lname,username,password) VALUES (2,'somename','somelastname','someusername','someAESencryptedPassword')
  </code></pre>
  
  <p>The reason I'm thinking such a query would exist/be possible is because when you backup a database with php myadmin (cpanel) and you open the file, you can actually view each insert to recreate the table with all rows a that point in time... </p>