select help needed

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

select help needed

Post by pelegk2 »

i have DB with 2 columns:
first colums is ID that can repeat itself
and the second column id amount

for exaple

a435f3 12
sadfsaf 10
a435f3 17
wer34 9


i want a print that
a435f3 total of 29
sadfsaf total of 10
wer34 total of 9

thanks in advance
peleg
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

This might work. Correct for correct column and table names, first.

$sql = "select id, sum(amount) from sometable group by id";

Might totally fail though.
Post Reply