Sum coloumn in mysql

Dear Experts,

I want to add two coloumn ( salary 1 and salary 2 )  from table salary  with condition "Where Address_name ="singapore",

Attached the table :

Appreciate for the answer,

Thank you

D--table.jpg
budi salehProject SchedulerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saurabh Singh TeotiaCommented:
If you just want to see overall salary of Singapore then you can do something like this...

select (sum(tb1.salary1)+sum(tb1.salary2)) as Overallsalary
from table_salary tb1
left join table_address tb2 on tb1.name_id=tb2.name_id
where tb2.address_name='Singapore'

Open in new window


Saurabh...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gplanaCommented:
I can see that you already have columns salary1 and salary2 on address table. So I'm guessing that you want to add these columns to another table and copy its contents.

On which table do you want to add these columns? On address? If so you can add the column and make it nullabe so only a few records will have this data.

Or maybe you want just get all the information together on a query for the addresses of singapore? If so you should execute a query similar to this:

SELECT Name, Address_name, Salary_1, Salary_2
FROM name n INNER JOIN address a ON n.Name_id = a.Name_id INNER JOIN salary s ON s.Name_id = n.Name_id
WHERE Address_name = 'singapore';

Hope this helps. Regards.
0
budi salehProject SchedulerAuthor Commented:
Thank everyone...appreciate the help from both of you..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.