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 |
|
gwfran
Starting Member
9 Posts |
Posted - 2004-08-10 : 19:14:40
|
| Okay, stuck again. I can't figure out why, when I don't have any records for the COMPOUND_LOT, COMPOUND_JUNCTION, or REPETITIONS tables, I get no output. I should at least get the results from the COMPOUNDS table (shouldn't I?). Even when I have records in COMPOUND_LOT, I still don't get any output. Only when I have COMPOUNDS all the way through REPETITIONS populated do I get output.Here's the heirarchy and the SQL statement:COMPOUNDS|COMPOUND_LOT|COMPOUND_JUNCTION|REPETITIONSSELECT COMPOUNDS.*, COMPOUND_LOT.*FROM COMPOUNDS INNER JOIN COMPOUND_LOT ON COMPOUNDS.CMPD_NUMBER = COMPOUND_LOT.CMPD_NUMBER INNER JOIN COMPOUND_JUNCTION ON COMPOUND_LOT.LOT_INDEX = COMPOUND_JUNCTION.LOT_INDEX INNER JOIN REPETITIONS ON COMPOUND_JUNCTION.JUNCTION_INDEX = REPETITIONS.JUNCTION_INDEXWHERE (COMPOUNDS.CMPD_NUMBER = ?) |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2004-08-10 : 19:30:57
|
| You probably need to replace the INNER JOIN's with LEFT JOIN's. Inner joins are fine only when you have related data in both tables. Left joins will return data from the first table regardless of whether there is matching data in the other table. Have a look at Books Online for a primer on join types. |
 |
|
|
gwfran
Starting Member
9 Posts |
Posted - 2004-08-10 : 19:46:07
|
| OMG... I need a vacation...Thanks Timmy - you've restored my sanity. |
 |
|
|
|
|
|