MySQL Forums
Forum List  »  PHP

Re: how to do calculations ??
Posted by: Peter Brawley
Date: March 11, 2014 10:17AM

> table1.row3 + table2.row2 - table3.row3 Is it possible to do this in mysql?

A database is not a spreadsheet. In SQL, table rows are referenced by key values. If you need to reference values by row and column number, consider using a spreadsheet frontend. You could still use MySQL as a storage backend.

> 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 : (

Read the manual page for mysqli_query(). It returns a result resource which must then be polled by a mysqli_fetch...() function to retrieve data in the result.

> when i have some floating point i get some redicular long number..

Floating point has rounding errorsd, do not use it for money; use DECIMAL.

Options: ReplyQuote


Subject
Written By
Posted
Re: how to do calculations ??
March 11, 2014 10:17AM


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.