php - mysql query for this -


hello mysql query output example...

            'table 1             | id |date        |             | 1  |01/01/2015  |             | 2  |01/02/2015  |             | 3  |01/01/2015  |             | 4  |01/02/2015  |               'table 2             |id |table1_id| value1| value2| value3|value4|             | 1 |   1     |  5    |    2  |   4   |  4   |             | 2 |   2     |  40   |    3  |   2   |  3   |               | 3 |   3     |   5   |    2  |   4   |  5   |             | 4 |   4     |       |    4  |   2   |  3   | 

sample

$result = ($value1 * $value2) + ($value3 + $value4);               if($value1 == ""){              }else{             $result = ($value1 * $value2) + ($value3 + $value4);             } 

sum same date... here's final output....

           date             finalvalue            01/01/2015          37            01/02/2015          125 

thanks in advance..

i think want :

select table1.date, sum(table2.value1) + sum(table2.value2) + sum(table2.value3) + sum(table2.value4) finalvalue table1 inner join table2 on table1.id = table2.table1_id group table1.date 

don't sum in php, can (more efficiently) in sql query.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -