title: PostgreSQL - Update column in table by reading from other table
body: <p>I'm trying to update <strong>SKU</strong> column in <strong>product_identifier</strong> table by using same value from <strong>product_stock</strong> table.
  I cannot do that directly. First i have to get <strong>variant id</strong> from <strong>product_variant</strong> then find <strong>SKU</strong> from <strong>product_stock</strong> by using variant_id
  And finally update SKU column in product_identifier table with variant's SKU</p>
  
  <pre><code>product_id = SELECT id FROM product
  
  variant_id = SELECT id FROM product_variant WHERE product_id=product_id
  
  sku = SELECT sku FROM product_stock WHERE variant_id=variant_id
  
  UPDATE product_identifier SET sku='sku'
  </code></pre>
  
  <p>(sorry, i've little SQL knowledge. tried to explain it by assiging it to value)</p>
  
  <p>Summary of code above:</p>
  
  <p>Fetch product ids from PRODUCT table</p>
  
  <p>Find variant ids of the product using product id</p>
  
  <p>Find SKU code of the variant id</p>
  
  <p>Then update SKU value in product_identifier using product id</p>
  
  <p>--
  Table Samples</p>
  
  <p>PRODUCT
  <a href="https://i.stack.imgur.com/gk1HX.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>PRODUCT_VARIANT
  <a href="https://i.stack.imgur.com/5dIca.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>PRODUCT_STOCK
  <a href="https://i.stack.imgur.com/ApaVp.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>--
  <em>PS. One product might have many variants</em></p>