Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Undying
Starting Member
2 Posts |
Posted - 2009-07-13 : 07:53:47
|
| Hi, I have a major problem. I was asked to create a reference table which is exactly the same as the existing reference table in our database in the office. here are the details.TABLEA TABLEB TABLEC (reference table)AID ACODE BID BCODE AID BID1 BACTEC 1 Bdata1 1 42 BLAST 2 Bdata2 1 2 3 ASQW 3 Bdata3 2 14 MERE 4 Bdata4 3 (NULL) the script to join this 3 tables isselect TABLEA.AID as A_ID,TABLEA.ACODE,TABLEC.AID as C_AID,TABLE.CID as C_BID,TABLEB.BID as B_ID,TABLEA.BCODEFROM TABLEA LEFT OUTER JOIN TABLEC ON(TABLEA.AID = TABLEC.AID (+)) AND LEFT OUTER JOIN TABLEB ON(TABLEC.BID = TABLEB.BID (+))ORDER BY TABLEA.BCODE******Now my problem is to query a table which is the same as TABLEC(TABLED). But joining another table with outer join is not possible with this kind of table relationship.TABLEDAID BID1 41 33 14 (NULL)Can anybody give me a good solution on how to query with this added table. I must use the new table at all costs. Thanks a lot in advance. It would be very much appreciated if someone can give me a good solution.I won't lower my standard to raise yours. |
|
|
Undying
Starting Member
2 Posts |
Posted - 2009-07-13 : 07:55:48
|
quote: Originally posted by Undying Hi, I have a major problem. I was asked to create a reference table which is exactly the same as the existing reference table in our database in the office. here are the details.TABLEA TABLEB TABLEC (reference table)AID ACODE BID BCODE AID BID1 BACTEC 1 Bdata1 1 42 BLAST 2 Bdata2 1 2 3 ASQW 3 Bdata3 2 14 MERE 4 Bdata4 3 (NULL) the script to join this 3 tables isselect TABLEA.AID as A_ID,TABLEA.ACODE,TABLEC.AID as C_AID,TABLE.CID as C_BID,TABLEB.BID as B_ID,TABLEA.BCODEFROM TABLEA LEFT OUTER JOIN TABLEC ON(TABLEA.AID = TABLEC.AID (+)) AND LEFT OUTER JOIN TABLEB ON(TABLEC.BID = TABLEB.BID (+))ORDER BY TABLEA.BCODE******Now my problem is to query a table which is the same as TABLEC(TABLED). But joining another table with outer join is not possible with this kind of table relationship.TABLEDAID BID1 41 33 14 (NULL)Can anybody give me a good solution on how to query with this added table. I must use the new table at all costs. Thanks a lot in advance. It would be very much appreciated if someone can give me a good solution.I won't lower my standard to raise yours.
Here again are the tablesTABLEA AID ACODE 1 BACTEC 2 BLAST 3 ASQW 4 MERE TABLEB BID BCODE 1 Bdata1 2 Bdata2 3 Bdata3 4 Bdata4 TABLEC (reference table)AID BID 1 4 1 2 2 1 3 (NULL) I won't lower my standard to raise yours. |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2009-07-13 : 11:05:41
|
| I am confused. Can you follow the link entitled How to ask and post your question again?http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|
|
|
|
|