Forum Moderators: coopster

Message Too Old, No Replies

multiple queries

         

Skills

11:36 am on Feb 12, 2004 (gmt 0)



Can anyone please help me I'm pulling my hair out here :)

I need to query a table called 'members' to find all the 'userid's' that like surfing=yes

I then have to query a table called 'spent' where sid=all_the_userid's_pulled_from_the_first_query then i would like to display the total amount in the column called 'how_much'

If some one would help me i would be most grateful.

scumm_bar2

1:16 pm on Feb 12, 2004 (gmt 0)

10+ Year Member



It might help to explain the structure on your tables better, and provide a little sample data. It sounds like you need to do a query on those two tables together using JOIN, and with that use SUM to get the total amount.

coopster

9:41 pm on Feb 12, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Skills!

If

spent.how_much
is a summarized total of spending, you would just need to join the two tables and use a WHERE condition:

SELECT * FROM members, spent
WHERE members.userid = spent.sid
AND members.surfing = 'yes'

If

how_much
is not a column in the
spent
table, then you may need to provide more details about your table structure as scumm_bar2 stated.