title: UPDATE with JOIN and condition SQL
body: <p>I have 2 tables and I'm trying to update one of the columns in one of them using the data from the second one. The SQL I have is as follows:</p>
  
  <pre><code>UPDATE 
          table_one
  SET 
          contents = CONCAT('https://someurl.com/', table_one.id, '.', split_part(T2.file_name, '.', 2))  
  FROM 
          table_one T1
  JOIN 
          table_two T2
  ON 
          T1.id = T2.image_id
  WHERE   
          T1.kind IN ('image')
  </code></pre>
  
  <p>What I'm trying to do is take the value of <code>file_name</code> column of table <code>table_two</code> and insert it into the <code>contents</code> column of <code>table_one</code> for the given id and for the kind 'image' which is a column of <code>table_1</code>. So the update should happen only for the records with kind='image' The split and concat part is done to get the extension of the file.</p>
  
  <p>This works but it updates all of the entries without taking into the consideration the kind which is set to be 'image'. Also it seems it's getting all of the same values because all of the extensions are set the same.</p>
  
  <p>Could anybody point to what I'm doing wrong, please?</p>
  
  <p><strong>Update:</strong> I'm using Postgres.</p>
  
  <p>Thanks.</p>