title: SQL Updating Rows Without Knowing Column Name
body: <p>I am attempting to create a stored procedure that will update a specific row and column location based on user input.  My table has approximately 100 columns utilizing names in progressive increments. Ex Page1, Page2, Page3, Page 4.... etc.  The data must also be updated in progressive increments as users finish different versions of each page.</p>
  
  <p>When the procedure is called I need it to find the user's row(Page1 is the key and unique), and put the information in where their version of the file is saved into the first NULL column.  I have seen talk about using cursors for similar applications but I am not sure if this is the proper solution.</p>
  
  <pre><code> ----------------------------------------------------
   |  Page1    |   Page2    |   Page3    |   Page4    |   
   ----------------------------------------------------
   |  /pg1.htm |   /pg2.htm |  /pg3.htm  |   NULL     |
   ----------------------------------------------------
   | /pg1.doc  |   /pg2.doc |   NULL     |   NULL     |
   ----------------------------------------------------
   | /pg1.pdf  |  NULL      |   NULL     |   NULL     |
   ----------------------------------------------------
  </code></pre>
  
  <p>I need the procedure to update the row sequentially each time with one piece of data when it is called.  My issue is in making this scaleable instead of limiting it with 100 + IF statements.</p>
  
  <p>The pseudo code I cooked up looks like this but is terribly inefficient:</p>
  
  <pre><code> FIND ROW that matches unique key
   LOOP Find_NULL
       IF Column2 == NULL
           UPDATE DATA HERE
       ELSE IF Column3 == NULL
           UPDATE DATA HERE
       ELSE IF Column4 == NULL
           UPDATE DATA HERE
       ELSE IF.... and on and on
   END LOOP Find_NULL
  </code></pre>
  
  <p>I am utilizing MySQL which I have  been told does not support Dynamic SQL. I attempted to create a variable and modify it as I went through the data to store the next NULL column however this did not work.</p>
  
  <p>If anyone has any solutions or advice I would appreciate it.</p>
  
  <p>Thanks in advance.</p>