A Digital Age Deserves A Digital Leader

Field Addition in MySQL

Field Addition in MySQL

Postby Fhaar » Thu Jul 19, 2007 5:48 pm

I have a table that contains a field for each entry called PLD (matches played). I would like to know if it's possible to perform a query that will add all the fields together with the exception of when they're not active(0). Here's how I'm doing it at the moment:

Code: Select all
$q1 = mysql_query("SELECT PLD FROM $table WHERE active!=0") or die (mysql_error());
while ($r1 = mysql_fetch_array($q1))
{
   $matchesPlayed = $matchesPlayed + $r1[PLD];
   
}
echo $matchesPlayed;
PRO Level 2
Posts: 28
Joined: Fri Jul 06, 2007 3:59 pm
Location: England

Return to HTML, CSS, and Scripts

Who is online

Users browsing this forum: No registered users and 6 guests

cron
cron