MySQL Forums
Forum List  »  PHP

how to do calculations ??
Posted by: theodor michailow
Date: March 11, 2014 03:35AM

Hi there , im making a db dor a service shop and i have 3 or posibly more tables with diferent values and now i want to take the rows and do calculations with them

for example: table1.row3 + table2.row2 - table3.row3 Is it possible to do this in mysql??? i can summ all colums from one table but i can`t figure it out how to make it work when i want to include more then 1 table...

$result2 = mysqli_query($con,"SELECT sum(salePrice) AS totalSale FROM sale"); From this i get the total of all fields FROM table sales but how can i take this value and add it with the sum of another table?

I tryed to store the result in a php value but PHP doesn`t store the value ... i don`t know why...

I tried somethink like this:

$result2 = mysqli_query($con,"SELECT sum(salePrice) AS totalSale FROM sale");
$resultsale=result2;

but i don`t get the value : (


is there a way to doe this? can i do something like this

SELECT sum(field1) AS total1 FROM table1 & sum(field2) AS total2 FROM table2
& sum(field3) AS total3 FROM table 3

and then make calculations with total1 total2 and total3????

i hope you can understand me.

Options: ReplyQuote


Subject
Written By
Posted
how to do calculations ??
March 11, 2014 03:35AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.