Hi
I've to Mysql tables that as follow:
Table 1 called "typeofcall" has one field called "TypeOfCallE" and has 3 registers:
CALLSACCEPTED
CallAnswer
ABANDONEDNO
And Table 2 called report2 and has 3 fields: "CALLSACCEPTED", "CallAnswer" and "ABANDONEDNO" with folowing data:
CALLSACCEPTED CallAnswer ABANDONEDNO
3 2 1
4 2 2
I'm trying to make a first query on Table 1 (typeofcall) an according to each result of first query, doing a second query (nested query) and total fields on table 2 "report2": addition result has to be: CALLSACCEPTED=7, CallAnswer=4 and ABANDONEDNO=3
I can see the results but multiplied by 3, for example: $TotalAccep= 21 (It has to be 7).
Please, any Ideas?
I've to Mysql tables that as follow:
Table 1 called "typeofcall" has one field called "TypeOfCallE" and has 3 registers:
CALLSACCEPTED
CallAnswer
ABANDONEDNO
And Table 2 called report2 and has 3 fields: "CALLSACCEPTED", "CallAnswer" and "ABANDONEDNO" with folowing data:
CALLSACCEPTED CallAnswer ABANDONEDNO
3 2 1
4 2 2
I'm trying to make a first query on Table 1 (typeofcall) an according to each result of first query, doing a second query (nested query) and total fields on table 2 "report2": addition result has to be: CALLSACCEPTED=7, CallAnswer=4 and ABANDONEDNO=3
PHP:
//First Query
$query1 = "SELECT TypeOfCallE".
"FROM typeofcall ";
"ORDER BY typeofcall DESC ";
$result1 = mysql_query($query1) or die(mysql_error());
while($row1 = mysql_fetch_array($result1))
{
//Nested Query 2 According to First Query
$query2 = "SELECT typeofcall .typeofcallE, report2.CALLSACCEPTED, report2.CallAnswer,
report2.ABANDONEDNO ".
"FROM typeofcall , report2 ";
$result2 = mysql_query($query2) or die(mysql_error());
while($row2 = mysql_fetch_array($result2))
{
//Total Call Accepted
if ($row1['TypeOfCallE']=="CALLSACCEPTED")
{
$TotalAccep=$TotalAccep+$row2['CALLSACCEPTED'];
}
//TotalCall Answer
if ($row1['TypeOfCallE']=="CallAnswer")
{
$TotalCallAnswer=$TotalCallAnswer+$row2['CallAnswer'];
}
//Total Call Aband.
if ($row1['TypeOfCallE']=="CallAnswer")
{
$TotalCallAband=$TotalCallAband+$row2['ABANDONEDNO'];
}
} // Second Query
} // Firts Query
echo $TotalAccep;
echo "-";
echo $TotalCallAnswer;
echo "-";
echo $TotalCallAband;
echo "-";
?>
I can see the results but multiplied by 3, for example: $TotalAccep= 21 (It has to be 7).
Please, any Ideas?