Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help qith parent/child query

Status
Not open for further replies.

JVZ

Programmer
Sep 3, 2002
205
0
0
CA
I need some help in writing a query; I have three tables for example, 1 Parent table, 1 child table, and 1 rules table. The rules apply to all the Childs of the parent. So for example:


PARENT_TABLE
---------------
PARENT_ID
PARENT_NAME


CHILD_TABLE
-------------
CHILD_ID
CHILD_PARENT_ID
CHILD_NAME


RULES
--------------
RULE_ID
RULE_PARENT_ID
RULE_PARENT_CODE_INDR
RULE_PARENT_ZONE_INDR


What I would like my result to like is:

CHILD_ID
RULE_PARENT_CODE_INDR
RULE_PARENT_ZONE_INDR

So basically I want to select all the Childs owned by the parent and the other fields in the rules table. For the life of me I can not get the right results... any ideas. ?


Thanks
 
Basic query, without knowing anything else:

Code:
SELECT A.CHILD_ID, B.RULE_PARENT_CODE_INDR,
       B.RULE_PARENT_ZONE_INDR
FROM   CHILD_TABLE A 
JOIN   RULES B
ON     A.CHILD_PARENT_ID=B.RULE_PARENT_ID

Tim
 
Thanks you... It seems (for me at least) the simplest problem give me the greatest problem :0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top