anser316 Posted April 14, 2008 Share Posted April 14, 2008 If there is no data in x.stock, how do i put the value '0' in total_stock. I get a blank as it has NULL. If it helps, total_stock is float, and stock is int $result2 =mysql_query("UPDATE branch_items i SET i.total_stock=(SELECT SUM(x.stock) from stock_expdates x WHERE x.drug_id=$drug AND i.drug_id=x.drug_id) WHERE i.drug_id=$drug") $result3 =mysql_query("SELECT total_stock from branch_items WHERE drug_id=$drug")or die ("Query:<br>$result3<br>Error:<br>".mysql_error());; $row = mysql_fetch_array( $result3 ); echo $row[total_stock]; Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted April 14, 2008 Share Posted April 14, 2008 Change the column definition to be non-null and make the default value 0. Unless there's a good reason for it to be null? Quote Link to comment Share on other sites More sharing options...
anser316 Posted April 14, 2008 Author Share Posted April 14, 2008 i had it as null, because i add data using php (sum) but i think now that if i have a default value of 0, then it can and should be not null. thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.