Not Null Query

Codes here !

Moderators: macek, egami, gesf


Postby DoppyNL » Fri Oct 18, 2002 1:18 pm

Querys handle projections and restrictions
"select projection from table where restriction.

projections: wich fields do you want to see
restrictions: wich records do you want to see

you can't hide empty fields in some records and show them in other records. You need to live with that, or use 2 different query's

Greetz Daan

Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Sun Oct 20, 2002 2:52 am

or try do

Code: Select all

if ($data['name'] != "")
echo "Name = $data[name]";

if ($data['email'] != "")
echo "Emai l= $data[email]";

if ($data['age'] != "")
echo "Age = $data[age]";


Re: Not Null Query

Postby Jay » Sun Oct 20, 2002 3:58 am

torosco wrote:HELP! I'm trying to write a query that will display all values from a table exept the tuples that are null. For example I have a table
Name: John
Email: null

Name: Joe
age: null

I want the query to show me:
Name: John
Age: 21

Name: Joe


What you need is:

Code: Select all

$query = "select Name,email,Age from table";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
     foreach($row as $key => $value) {
          if (!is_null($value)) print "$key: $value\n";

And that should sort it out

Return to “mySQL & php coding”

Who is online

Users browsing this forum: Baidu [Spider] and 5 guests