Jump to content


Photo

Need help with syntax for sum in mysql query


  • Please log in to reply
1 reply to this topic

#1 jacob

jacob
  • Members
  • Pip
  • Newbie
  • 2 posts

Posted 14 November 2005 - 02:05 AM

Hello everyone, I currently working on a project to show price estimation which requires me to sum a value from two tables in mysql. Ok, below are the tables and values that I have. in example, From these table, I need to get sum price value for car in table1 with price value of india in table2. What would be the mysql syntax? thank you in advance for your help.

table1

follow_by price
car | 500
foot | 1000

table2

location price
china | 10000
india | 15000
thailand | 20000


#2 Cook

Cook
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts
  • LocationSingapore

Posted 14 November 2005 - 03:01 AM

SELECT (`table1`.`car` + `table2`.`india`) AS `price_estimation` FROM `table1`, `table2` WHERE (some condition of yours)

Cook




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users