Null values in MySQL database

Hi!,
I have a contacts table in MySQL and I want output in a select menu.
Problem is, some rows dont have any record in it, and it is displayed in very odd way as it outputs blank fields and some data in between.

My overall code is:,

<?PHP
$query=mysql_query("SELECT * FROM call_details WHERE !ISNULL(call_project_name)");
echo "<select name='detailr'>";
while($row=mysql_fetch_array($query))
{
echo "<option value=$row[call_id]>
$row[call_project_name]</option>";
}
echo "</select>";
?>

Please help me out in this matter :frowning:

$query=mysql_query("SELECT * FROM call_details WHERE call_project_name!=‘’ ");
here,
call_project_name!=‘’ //these are single cotes ’ ’

You cannot negate like that in MySQL. :wink:


SELECT this, that FROM table WHERE that IS NOT NULL

ok, i learned a good expression to write the query how to use nulls.
Thank you, Anthony.

but when i execute the query i am getting an empty field records also.
here is query;;;

SELECT * FROM company_table WHERE profile_long IS NOT NULL;

this query showing records as same as SELECT * FROM company_table;

$query=mysql_query("SELECT profile_long FROM company_table WHERE profile_long IS NOT NULL ");

This will work fine!!:slight_smile: Thanks a lot Anthony.

An empty string and null are not the same thing.

try

SELECT * FROM company_table
WHERE profile_long IS NOT NULL
and profile_long <> ''

that’s actually redundant, all you need is

WHERE profile_long > ''

:cool:

thanks :slight_smile: