SQL SELECT from third level table
Posted
by
Spidermain50
on Stack Overflow
See other posts from Stack Overflow
or by Spidermain50
Published on 2010-12-28T22:57:46Z
Indexed on
2010/12/29
7:54 UTC
Read the original article
Hit count: 153
sql
Ok I know little about SQL so bare with me...
I'm trying to see if certain values exist in a third level table and I don't know how to go about it. Here is the scenario...
I have a Accident table that holds accident information. It has 3 one-to-many child tables (Units, Occupants, NonMotorists). An each of those child tables have their own many-to-many child table (Alcohol). I need to be able to have some way of seeing if a range of values exists in a field in those Alcohol tables. Here is watered down version of what my structure for the tables looks like...
--tblAccident--_
PK_AccidentNumber
--tblAccidentUnit--
PK_PrimaryKey
FK_AccidentNumber
--tblAccidentOccupant--
PK_PrimaryKey
FK_AccidentNumber
--tblAccidentNonMotorist--
PK_PrimaryKey
FK_AccidentNumber
--tblAccidentUnitAlcohol--
PK_PrimaryKey
FK_ForeignKey
AlcoholValue <---- THIS IS WHAT I NEED TO SEARCH
--tblAccidentOccupantAlcohol--
PK_PrimaryKey
FK_ForeignKey
AlcoholValue <---- THIS IS WHAT I NEED TO SEARCH
--tblAccidentNonMotoristAlcohol--
PK_PrimaryKey
FK_ForeignKey
AlcoholValue <---- THIS IS WHAT I NEED TO SEARCH
I hope this makes some sense as to what i am trying to accomplish. thank you
© Stack Overflow or respective owner