title: How to Replace and Update Data From One Table to Another Table in MySQL
body: <p>I am using PHP, MySQL. I have two tables</p>
  
  <p>1.categories </p>
  
  <pre><code>cat_id   cat_name
  
  1        cars
  2        mobile
  3        computers
  4        radios
  </code></pre>
  
  <p>2.posts</p>
  
  <pre><code>id       title     body    cat_id
  
  1        title1    txt1    cars
  2        title2    txt2    mobiles
  3        title3    txt3    mobiles 
  4        title4    txt4    radios
  </code></pre>
  
  <p>And I want to update the posts table replacing the cat_id value with categories table and want the following output</p>
  
  <pre><code>id       title     body    cat_id
  
  1        title1    txt1    1
  2        title2    txt2    2
  3        title3    txt3    2
  4        title4    txt4    4
  </code></pre>
  
  <p>Is there Any SQL Statement That Can Do this in One Go?</p>