Jump to content

Recommended Posts

Hi

 

Trying to learn MysQL and have a calculation problem. I want a query to do the following example (all are floats with numbers to add) -

 

SELECT a+b+c+d+e AS result FROM table

 

The above obviously dosen\'t work, where, this line below does -

 

SELECT a+b AS result FROM table (and gives me the total of the two fields). Can I calculate all five fields somehow and create a result field?

 

Thanks in advance - Pat J

Link to comment
https://forums.phpfreaks.com/topic/135-mysql-calculation/
Share on other sites

Well....

 

select 1+2+3+4+5 AS result;

 

does work fine enough....

 

So

 

select (a+b+c) as result from table;

 

should work as well.... check your syntax and if you are absolutely sure that there is something wrong, then please post some more info on tables and variables...

 

But you are using the correct syntax. It should work.

 

P.

Link to comment
https://forums.phpfreaks.com/topic/135-mysql-calculation/#findComment-407
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.