Page 1 of 1

built-in functions in mySQL???

Posted: Sat Jul 10, 2004 12:23 pm
by Joe
Is there any built in functions in mySQL that allows you to "ADD" certain columns?. I have been trying to total a customers pricing so the admin can see the results though the administration panel with no luck.

Regards


Joe 8)

Posted: Sat Jul 10, 2004 12:37 pm
by markl999
MySQL has a SUM() function, see the docs for more info.

Posted: Sat Jul 10, 2004 12:37 pm
by Joe
OK thanks alot mark. Much appreciated!

Posted: Sat Jul 10, 2004 12:41 pm
by Joe
Another question on this topic actually. Is it possible to use

SELECT SUM(column1,column2,column3) FROM tablename

instead of:

SELECT SUM(column1) FROM tablename

Or does this have to be done differently like:

SELECT SUM(column1) AS column1, SUM(column2) AS column2, SUM(column3) AS column3 FROM tablename

Regards


Joe 8)

Posted: Sat Jul 10, 2004 1:52 pm
by markl999
Not sure, what happened when you tried it? ;)

Posted: Sat Jul 10, 2004 3:18 pm
by Weirdan
what about:

Code: Select all

select column1+column2+column3 as total from .......
?