SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: WHERE clause on JOIN query???
Hybrid View
-
Jan 25, 2002, 09:14 #1
- Join Date
- Mar 2001
- Location
- London | UK
- Posts
- 1,140
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
WHERE clause on JOIN query???
I have this query:
Code:$sql = " SELECT unbilled_item.job_number, SUM(unbilled_item.amount) AS total_unbilled, job.project_manager FROM unbilled_item LEFT JOIN job ON (unbilled_item.job_number=job.job_number) GROUP BY job.project_manager ORDER BY total_unbilled DESC " ;
Code:WHERE user.office = "xxx"
I can't work it out.
-
Jan 25, 2002, 11:11 #2
- Join Date
- Nov 1999
- Location
- Mechanicsburg, PA
- Posts
- 7,294
- Mentioned
- 123 Post(s)
- Tagged
- 1 Thread(s)
You would need to add the user table to the query, of course, and you would probably need to rework the query a bit, but it should be possible....
Dave Maxwell - Manage Your Site Team Leader
My favorite YouTube Video! | Star Wars, Dr Suess Style
Learn how to be ready for The Forums' Move to Discourse
-
Jan 25, 2002, 11:30 #3
- Join Date
- Mar 2001
- Location
- London | UK
- Posts
- 1,140
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's OK, today's query of the day is:
Code:$sql = " SELECT SUM(unbilled_item.amount) AS total_unbilled, user.office, user.first_name, user.surname FROM job LEFT JOIN unbilled_item ON (job.job_number=unbilled_item.job_number) LEFT JOIN user ON (job.project_manager=user.employee_number) WHERE user.office = $office GROUP BY job.project_manager ORDER BY total_unbilled DESC " ;
Bookmarks