Jump to content

Recommended Posts

I recently took over a project for a local non-prof that holds a run/walk event to raise funds each year.  I'm having a heck of a time coming up with the query to get the report they're asking for.

 

Here's what they'd like to see:

Pack Name: Bob's Pack
     Bob    29.95
     Susie  0
     Total: 29.95

     
Pack Name: Joe's Pack
     Joe    39.90
     Total: 39.90

     
Grand Total: 59.90

 

Here are the tables:

Tables: transactions

transactionID  transactionAmount   transactionReasonCode    walkerID
1              29.95               1                        1
2              19.95               1                        3
3              19.95               1                        3



Table: walkers

walkerID  walkPackID     walkerName
1         1              Bob
2         1              Susie
3         3              Joe



Table: Packs

packID    walkerID       packName
1         1              Bob's Pack
3         3              Joe's Pack

 

And here's my query so far:

SELECT packs.packName, walkers.walkerID 
COUNT (transactions.transactionAmount) AS total 
FROM transactions, packs, walkers 
WHERE transactions.transactionReasonCode=1 
AND walkers.walkerID = transactions.walkerID 
AND packs.packID = walkers.walkPackID 
GROUP BY walkers.walkPackID

 

Obviously the query isn't working but can someone lend me a hand? I've been looking through Paul DuBois book and feel that I'm heading in the right direction but I've run into a wall.

They're using PHP 5 and MySQL 4.

 

Thanks a ton.

Link to comment
https://forums.phpfreaks.com/topic/125225-noob-needs-a-hand-with-joins/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.