SunQuest
 
           MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old December 10th, 2004, 07:57 PM
aussiev8 aussiev8 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 1 aussiev8 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
complicated join

3 tables:

customer
---------
custiomer_id - PK
name

assignment
-----------
assignment_id - PK
customer_id - FK

assignment_event
-----------------
assignment_event_id - PK
assignment_id - FK
closed
event_desc


ok so i need to get all the event's that are closed for a particular assignment relating to a particluar customer.. so for example.

SELECT c.customer_name, c.customer.id, t.event_desc, t.closed
from customer AS c, event_type AS t, assignment_event AS a
where c.customer_id = a.customer_id and a.assignment_id = t.assignment_id and t.closed = 1,

do you guys understand? this is prob simple as hell, i'm just really new to this sort of stuff, and have searched google for a while but i can't really get my head around it all!

Reply With Quote
  #2  
Old December 13th, 2004, 10:05 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Try this... I'm not positive it will work, but its a start...
I noticed some spelling mistakes in your post... I hope that was from you typing it out and not actual fieldnames in the table.

Code:
SELECT customer.customer_name, customer.customer.id, 
           assignment_event.event_desc, assignment_event.closed
FROM customer, assignment, assignment_event
WHERE customer.customer_id=assignment.customer_id
    AND assignment.assignment_id=assignment_event.assignme  nt_id
    AND customer.customer_id=1
    AND assignment_event.closed=1


I made the changable-values green..

Reply With Quote
  #3  
Old December 13th, 2004, 10:06 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
It seems the forum has added peculiar spaces to one of my fieldnames in the WHERE clause... be sure to fix that when you copy&paste

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > complicated join


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway