title: Mysql - how to UPDATE table from another table with several WHERE conditions
body: <p>I have 2 tables:</p>
  <p>table1 which looks like:</p>
  <blockquote>
  <p>column1 | column2 | item1 | item2 | item3 | item4 | (it goes till item50)</p>
  <p>value   | value   | value | value | value | value | .........</p>
  </blockquote>
  <p>table_to_update that looks like:</p>
  <blockquote>
  <p>column1 | colum2 | item</p>
  <p>value   | value  | value of item1</p>
  <p>value   | value  | value of item2</p>
  <p>value   | value  | value of item3</p>
  <p>value   | value  | value of item4</p>
  <p>value   | value  | value of item....</p>
  </blockquote>
  <p>when I change in table1 the value of colum1 or column2 then I want these data changed in table_to_update. Note values of items 1-50 never change</p>
  <p>So I can update value of item1 by using this PHP commands:</p>
  <pre><code>UPDATE table_to_update, table1
  SET table_to_update.column1 = table1.column1, table_to_update.column2 = table1.column2
  WHERE table_to_update.item = table1.item1
  </code></pre>
  <p>Then value of item2 with:</p>
  <pre><code>UPDATE table_to_update, table1
  SET table_to_update.column1 = table1.column1, table_to_update.column2 = table1.column2
  WHERE table_to_update.item = table1.item2
  </code></pre>
  <p>(all the same but table1.item1 is changed to table1.item2)</p>
  <p>And do that 50 times which is obviously not very convenient</p>
  <p>Is there a way to only have the WHERE part changed, such as something like this (which is wrong):</p>
  <pre><code>UPDATE table_to_update, table1
  SET table_to_update.column1 = table1.column1, table_to_update.column2 = table1.column2
  WHERE table_to_update.item = table1.item1 (&quot;THEN&quot;) table_to_update.item = table1.item2 (&quot;THEN&quot;) table_to_update.item = table1.item3 ....
  </code></pre>
  <p>Alternatively I can write commands like below for the 50 items:</p>
  <pre><code>UPDATE table_to_update, table1
  SET table_to_update.column1 = table1.column1, table_to_update.column2 = table1.column2
  WHERE table_to_update.item = table1.item1
  
  UPDATE table_to_update, table1
  SET table_to_update.column1 = table1.column1, table_to_update.column2 = table1.column2
  WHERE table_to_update.item = table1.item2
  </code></pre>
  <p>but I don't know how to have them all run from 1 PHP page. It looks like I need to create 50 PHP pages with 1 statement each?</p>