title: copy data from 1 table to another table with checking for equal data
body: <p>I have been working on migrating a webshop. The company that did this did something wrong and I want to fix it myself. </p>
  
  <p><strong>The problem is:</strong><br/>
  I have 2 tables 1 from the old webshop (let's call this one <code>A</code>) and one from the new one (and we call this one <code>B</code>).</p>
  
  <p>Now the short description needs to be copied from <code>table A</code> to <code>table B</code>. The column name in <code>table A</code> is <code>meta_description</code> and in <code>table B</code> it is <code>description_short</code>. but I do not want to just copy and be done. Because when I do that everything will not be in order. Cause both tables are sorted differently. </p>
  
  <p>I got this far: </p>
  
  <pre><code>try {
      $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
      // set the PDO error mode to exception
      $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      $sql = "INSERT INTO pskd_product_lang (description_short)
  VALUES ($desc)";
      // use exec() because no results are returned
      $conn-&gt;exec($sql);
      echo "New record created successfully";
  }
  catch(PDOException $e)
  {
      echo $sql . "&lt;br&gt;" . $e-&gt;getMessage();
  }
  
  $conn = null;
  </code></pre>
  
  <p>where <code>$desc</code> is made here: </p>
  
  <pre><code>$conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  }
  
  $sql = "SELECT * FROM oc_product_description"; 
  $result = $conn-&gt;query($sql);
  
  if ($result-&gt;num_rows &gt; 0) {
      echo "&lt;table&gt;&lt;tr&gt;&lt;th&gt;ID&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;/tr&gt;";
      // output data of each row
      while($row = $result-&gt;fetch_assoc()) {
          $name = $row["name"];
          $desc = $row["meta_description"];
          echo "&lt;tr&gt;&lt;td&gt;".$name."&lt;/td&gt;&lt;td&gt;".$desc."&lt;/td&gt;&lt;/tr&gt;";
      }
      echo "&lt;/table&gt;";
  } else {
      echo "0 results";
  }
  $conn-&gt;close();
  </code></pre>
  
  <p>as you can see the target <code>table (B)</code> is called <code>pskd_product_lang</code>
  The source <code>table (A)</code> is called <code>oc_product_description</code> I tried were statements and a lot of other things I found on the internet but nothing worked... </p>
  
  <p>If someone could help me out or point me in the right direction I would be grateful!!</p>
  
  <p>Thanks in advance</p>