title: Update MYSQL row with non null value only
body: <p>i have a table contain huge number of rows and i need to update row with specific ID, for example assume i have a row with below details:</p>
  
  <pre><code>Id= 1
  Name= lessa
  Address = USA
  </code></pre>
  
  <p>now i used below PHP code to update the row:</p>
  
  <pre><code>&lt;?php
  $con = mysqli_connect("localhost","MyUserName","MyPassword","DB");
  $id = '1';
  $name = "";
  $address = "UK";
  // update only non value items
  $r=mysqli_query($sql);
  mysqli_close($con);
  ?&gt;
  </code></pre>
  
  <p>now my issue since the value of address is changed from USA to UK i need to update this value only, also since the name value is nothing the name should be remain so after update the row should be like below:</p>
  
  <pre><code>ID=1
  Name = lessa
  Address = UK
  </code></pre>
  
  <p>Also if in another time the name value changed and address remain the same i need to update the name only.</p>
  
  <p>also assume i have 100 column not only three as this example.</p>
  
  <p>any help for write the update statement will be appreciated.</p>
  
  <p>Update:</p>
  
  <p>I use below code but no update happen:</p>
  
  <pre><code>&lt;?php
  $con = mysqli_connect(DB info);
  $id = 'jo_12';
  $name = "";
  $address = "UK";
  $sql = "UPDATE info
          SET name = IF(? = '', name, ?),
              address = IF(? = '', address, ?)
          WHERE id = ?";
  $stmt = $con-&gt;prepare($sql);
  $stmt-&gt;bind_param("ssssi", $name, $name, $address, $address, $id);
  $stmt-&gt;execute();
  
  mysqli_close($con);
  ?&gt;
  </code></pre>