title: For empty value set to zero in MySQL
body: <p>I try to set empty MySQL value to zero. I used IFNULL but it doesn't work. Sorry for my bad english. </p>
  
  <pre><code>&lt;select name="stock_i_h_id" id="stock_i_h_id" class="form-control  m-bot15" required&gt;
  &lt;option value="" selected="selected"&gt;--Select Item --&lt;/option&gt;
  &lt;?php 
  $ids=array();
  $qry = mysql_query("SELECT IFNULL(stock_i_h_id,0) FROM other_stock_item_creation where userId='".$_SESSION['userId']."' and status_my='0'");
  while($row_sid =  mysql_fetch_assoc($qry)){
      $ids[]=$row_sid["stock_i_h_id"]; 
  }
  $st = implode(",",$ids);                    
  $ids2=array();
  $qry2 = mysql_query("SELECT IFNULL(stock_i_h_id,0) FROM dpr_stock_item where userId='".$_SESSION['userId']."' and status_my='0'");
  while($row_sid2 =  mysql_fetch_assoc($qry2)){
      $ids2[]=$row_sid2["stock_i_h_id"]; 
  }
  $st2 = implode(",",$ids2);
  
  $stock_item_head_name = mysql_query("select * from stock_item_head_name where userId='".$_SESSION['userId']."' and status_my='0' and id not in (".$st.",".$st2.") order by id ASC"); 
  $current_date= date('d-m-Y');
  while($rows_stock_item_head_name = mysql_fetch_assoc($stock_item_head_name)) 
  {
  ?&gt;
  &lt;option value="&lt;?php echo $rows_stock_item_head_name['id'] ?&gt;"&gt;&lt;?php echo $rows_stock_item_head_name['stock_item_name'] ?&gt;&lt;/option required&gt;
  &lt;?php 
  }
  ?&gt;
  </code></pre>
  
  <p>If <code>$qry</code> and <code>$qry2</code> returns empty value then both $st and $st2 becomes empty and then I get <code>NOT IN('','')</code> instead <code>NOT IN(0,0)</code> in the third query(<code>$stock_item_head_name</code>)</p>
  
  <p>Edit:
  My code works fine without <code>IFNULL</code> when both the tables <code>other_stock_item_creation</code> and <code>dpr_stock_item</code> have entries. But when the tables are empty it's not working with <code>IFNULL</code> or <code>IF(stock_i_h_id = '', 0, stock_i_hd)</code></p>