Jump to content


Photo

How to sum rows?


  • Please log in to reply
2 replies to this topic

#1 Darkness Soul

Darkness Soul
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts
  • LocationBrazil; São Paulo.

Posted 03 October 2006 - 08:03 PM

Yo,

I need a little help, maybe its simple, but i don't know how to do it!

At the index page, I have a table, with cars to be sold! like..

id ---36x ---60x ---
1 15
1 8
2 10
3 25
3 12


What I'm suppose to do, to sum these rows, and return something like it?:

id ---36x ---60x ---
1 158
2 10
3 2512


The data come from 3 tables, using joins.. someone know how i do to simplify this table?

Thank you!!

D.Soul
(If something is wrong, please tell me. I'm learning this language. Thank you)

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 October 2006 - 08:55 PM

Oh... you want to collapse/compress this layout... it sounds like you'll have to do it yourself in PHP, if you're getting back one row-one record.  It may be possible do accomplish this with a very ugly looking query, but I don't really see the point.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 Darkness Soul

Darkness Soul
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts
  • LocationBrazil; São Paulo.

Posted 03 October 2006 - 08:58 PM

I think about use an aux table to record it with the PHP, and then, liten all compressed.. =)

Thank you anyway ^^

D.Soul
(If something is wrong, please tell me. I'm learning this language. Thank you)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users