|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 |
|
#2
|
||||
|
||||
|
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
__________________
Look! Its a ShemZilla ![]() ![]()
|
|
#3
|
||||
|
||||
|
You are a genius. Thank you so much!
|
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > SQL join problem? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|