|
Posted by BearItAll on 06/21/05 11:24
On Tue, 21 Jun 2005 00:03:26 -0700, madsgormlarsen wrote:
> Hi
>
> I need to test a field(colum) in a SQL database for for NULL values, and
> have done so in this way.
>
> $query = "SELECT j FROM Andersen";
> $result = mysql_query($query, $link_id); $query_data =
> mysql_fetch_array($result); if (array_sum($query_data)==0)
> {
> echo "er nul";
> }
> }
>
>
>
> Does "mysql_fetch_array($result)" change the NULL values to zero values?
> And is there a better way of doing it.
It isn't really wise to assume NULL is equal to zero if they is a
possibility of your sql/script being ported to another database.
NULL is best thought of as an object rather than a value, so in your sql
you would test using 'is'.
Ex,
$query = "SELECT j FROM Andersen WHERE column IS NULL";
[Back to original message]
|