title: Query to get result from another id in one query
body: <p>I have the following simple table</p>
  <pre><code>product_id    vendor_id    product_gtin    product_parent_id
  646           1            123456789       0
  4502          2            202020255       646
  </code></pre>
  <p>As a result I would like to get the product gtin for the id 4502 from the product_parent</p>
  <p>Result example:</p>
  <pre><code>product_id    vendor_id    product_gtin    product_parent_id
  646           1            123456789       0
  4502          2            123456789       646
  </code></pre>
  <p>.</p>
  <pre><code>SELECT product_id, vendor_id, case when vendor_id !=1 then (select product_gtin from `products` where product_id = product_parent_id) else product_gtin end as gtin, product_parent_id FROM `products` where product_id in (646, 4502)
  </code></pre>
  <p>My problem is that while I run the query it does not know which id I refer to. So I get NULL as result for product_gtin for id 4502.</p>
  <p>Any suggestions how to solve it would be appreciated</p>