title: MySQL update with data from two tables
body: <p>I have a MySQL database with the two tables that I need modified. 
  The first table holds notes</p>
  
  <pre><code>id type note
  1  1    24 months warranty
  2  1    12 months warranty
  3  2    Garage in Denver
  4  3    Pre sales maintenance done
  ....
  </code></pre>
  
  <p>And then a vehicle table that holds many vehicle tables and a field that hold notes with their text instead of a pointer</p>
  
  <pre><code>id licence_plate  ... sales_notes ...
  1  XH34DN         ... &lt;warranty&gt;24 months warranty&lt;/warranty&gt;&lt;garage&gt;Garage in Denver&lt;/garage&gt;&lt;maintenance&gt;Pre sales maintenance done&lt;/maintenance&gt; ...
  2  K4B3C6         ... &lt;warranty&gt;12 months warranty&lt;/warranty&gt;&lt;garage&gt;Garage in Sacramento&lt;/garage&gt;&lt;maintenance&gt;Pre sales maintenance not done&lt;/maintenance&gt; ...
  </code></pre>
  
  <p>As you can imagine this is higly inneficient and I want to modify to pointers that hold the id of the note.</p>
  
  <pre><code>id licence_plate  ... warranty_note garage_note maintenace_note ...
  1  XH34DN         ... 1             3           4 ...
  2  K4B3C6         ... 2             7           12 ...
  </code></pre>
  
  <p>I can do it manual updates but I would like to build one that makes it automatically by type.</p>
  
  <p>So for notes.type=1 if the notes.note text is found in vehicle.sales_notes it updates the vehicle.warranty_note.</p>
  
  <p>Any idea how to build something like that?</p>
  
  <p>I have something like this in mind, but id doesn't work. No results are updated</p>
  
  <pre><code>UPDATE tx_vehicle v, tx_note n
  SET v.garage_note = n.uid
  WHERE v.sales_notes LIKE ('%'+n.note+'%')
  </code></pre>