SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old June 8th, 2005, 06:43 PM
delahlin's Avatar
delahlin delahlin is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 30 delahlin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 33 m 53 sec
Reputation Power: 5
SQL join problem?

I have data in table1 and table2 that are the same (client_id), and data in table2 and table3 that are the same (case_id). tables 1&3 are not related in any other way except through table2. I need data from table3 based on a select from table1.


table1---------table2----------table3
client_id-------client_id--------
---------------case_id---------case_id
-------------------------------'case_number' <--

(sorry if this is difficult to "decrypt")

I need "case_number" in table3 to be associated with client_id in table1. How do I make that happen? Would some kind of JOIN statement work here?

SELECT table1.client_id, table2.client_id, table2.case_id, table3.case_id, table3.case_number
FROM table1, table2, table3
WHERE table1.client_id = table2.client_id AND table2.case_id = table3.case_id

...or something like this? (This obviously doesn't work). Is there an easy way to do something like this? If it makes any difference, I'm using ASP and MS SQL.
__________________
Del

Last edited by delahlin : June 8th, 2005 at 06:56 PM. Reason: spacing

Reply With Quote
  #2  
Old June 9th, 2005, 02:43 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
HI,

you could use a multiple inner join:
Code:
 SELECT table1.client_id, table2.client_id, table2.case_id, table3.case_id, table3.case_number
 FROM table1
 INNER JOIN table2 ON table1.client_id = table2.client_id
 INNER JOIN table3 ON table2.case_id = table3.case_id
 

hope this helps
Comments on this post
delahlin agrees: Thank you!
__________________
Look! Its a ShemZilla



Reply With Quote
  #3  
Old June 9th, 2005, 11:43 AM
delahlin's Avatar
delahlin delahlin is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 30 delahlin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 33 m 53 sec
Reputation Power: 5
You are a genius. Thank you so much!

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > SQL join problem?


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



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT