NULL to 0

What modification does this query need that if either total_score or
questions_answered have a value of "NULL" that it will be changed to 0
("ZERO") Ron

SELECT SUM(`my_Bible_trivia_knowledge_questions_answered`.`score`) AS
total_score, `my_Bible_trivia_knowledge_profile`.`questions_answered` FROM
`my_Bible_trivia_knowledge_questions_answered` INNER JOIN
`my_Bible_trivia_knowledge_profile` ON
`my_Bible_trivia_knowledge_questions_answered`.`my_Bible_tri via_knowledge_profile_reference`
= `my_Bible_trivia_knowledge_profile`.`reference` WHERE
`my_Bible_trivia_knowledge_profile`.`ip_address` = '$ip_address'


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
ron.piggott [ So, 18 Juli 2010 04:15 ] [ ID #2044691 ]

Re: NULL to 0

SELECT
IFNULL(SUM(`my_Bible_trivia_knowledge_questions_answered`.`s core`),
0) AS total_score,
IFNULL(`my_Bible_trivia_knowledge_profile`.`questions_answer ed`, 0)
AS questions_answered

In these cases you must use the IFNULL function, for testing the value.

--
Andr=C3=A9s G. Monta=C3=B1ez
Zend Certified Engineer
Montevideo - Uruguay

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
andresmontanez [ So, 18 Juli 2010 04:20 ] [ ID #2044692 ]

Re: NULL to 0

--=-NcLvTGLgQAUKD5bjEfig
Content-Type: multipart/alternative; boundary="=-F++eSMoM27v/3jYVXIh9"


--=-F++eSMoM27v/3jYVXIh9
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable



Thanks, Ron

--





-----Original Message-----
From: Andr=C3=A9s G. Monta=C3=B1ez <andresmontanez [at] gmail.com>
To: ron.piggott [at] actsministries.org
Cc: php-db [at] lists.php.net
Subject: Re: [PHP-DB] NULL to 0
Date: Sat, 17 Jul 2010 23:20:20 -0300


SELECT
IFNULL(SUM(`my_Bible_trivia_knowledge_questions_answered`.`s core`),
0) AS total_score,
IFNULL(`my_Bible_trivia_knowledge_profile`.`questions_answer ed`, 0)
AS questions_answered

In these cases you must use the IFNULL function, for testing the value.

--
Andr=C3=A9s G. Monta=C3=B1ez
Zend Certified Engineer
Montevideo - Uruguay

--=-F++eSMoM27v/3jYVXIh9
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.30.2">
</HEAD>
<BODY>
<BR>
<BR>
Thanks, Ron<BR>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
--
<DIV ALIGN=center></DIV><BR>
<BR>
<DIV ALIGN=center><A HREF="http://www.TheVerseOfTheDay.info"><IMG SRC="cid:1279460692.1938.0.camel [at] localhost.localdomain" ALIGN="bottom" BORDER="0"></A></DIV>
<BR>
<BR>
</TD>
</TR>
</TABLE>
-----Original Message-----<BR>
<B>From</B>: Andrés G. Montañez <<A HREF="mailto:%3d%3fISO-8859-1%3fQ%3fAndr%3dE9s%3f%3d%20%22G.%22%20%3d%3fISO-8859-1%3fQ%3fMonta%3dF1ez%3f%3d%20%3candresmontanez [at] gmail.com%3e">andresmontanez [at] gmail.com</A>><BR>
<B>To</B>: <A HREF="mailto:ron.piggott [at] actsministries.org">ron.piggott [at] actsministries.org</A><BR>
<B>Cc</B>: <A HREF="mailto:php-db [at] lists.php.net">php-db [at] lists.php.net</A><BR>
<B>Subject</B>: Re: [PHP-DB] NULL to 0<BR>
<B>Date</B>: Sat, 17 Jul 2010 23:20:20 -0300<BR>
<BR>
<PRE>
SELECT
IFNULL(SUM(`my_Bible_trivia_knowledge_questions_answered`.`s core`),
0) AS total_score,
IFNULL(`my_Bible_trivia_knowledge_profile`.`questions_answer ed`, 0)
AS questions_answered

In these cases you must use the IFNULL function, for testing the value.

--
Andrés G. Montañez
Zend Certified Engineer
Montevideo - Uruguay
</PRE>
</BODY>
</HTML>

--=-F++eSMoM27v/3jYVXIh9--

--=-NcLvTGLgQAUKD5bjEfig--
ron.piggott [ So, 18 Juli 2010 15:44 ] [ ID #2044693 ]
PHP » gmane.comp.php.database » NULL to 0

Vorheriges Thema: always the logic that messes me up.... Database fun!
Nächstes Thema: calling a page for each row