title: SQL update set table if value in table A is equals to value in table B
body: <p>this query is working fine.</p>
  
  <pre><code>UPDATE data
     SET unit_id='a3110a89'
   WHERE unit_id='7d18289f';
  </code></pre>
  
  <p>Now, I need to run this query over 30 times
  so I made csv file import it to the DB with this command:</p>
  
  <pre><code>COPY mytable FROM 'D:/test.csv' WITH CSV HEADER DELIMITER AS ','
  </code></pre>
  
  <p>Now I have table called my table with 2 columns OLD and NEW
  i want to search the table "data" in column unit_id anywhere there if the value equals to the value in table "mytable.old" replace it with the value "mytable.new" on the same row.</p>
  
  <p>I tried to run this query but I get an error:</p>
  
  <pre><code>UPDATE data
     SET unit_id=(SELECT mytable."old" FROM public.mytable)
     WHERE unit_id=(SELECT mytable."new" FROM public.mytable)
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>more than one row returned by a subquery used as an expression
  </code></pre>
  
  <p>I think i'm just trying to do it in the wrong way...</p>
  
  <p>thx for the help!</p>
  
  <p>by the way Im using PostgreSQL</p>