English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Tbl 1: AcctNum, AcctName, AcctType Tbl2: AcctType, PackageName Tbl3: AcctName, PackageName, Cases.

There are multiple AcctTypes with multiple PackageNames. Tbl3 is the data table. In Tbl3, there are more PkgNames than what is in tbl2 for that acctName/AcctType. Problem is to account for missing PackageName in tbl3. Need to display all the packagenames from Tbl2 that correspond to a particular Acctname plus the fields from Tbl3
This is what I have so far but doesn't show all the PkgNames for that account
Select tbl2.PkgName, tbl3.Cases FROM tbl1 INNER JOIN(tbl2 INNER JOIN tbl3 ON tbl2.PkgName=tbl3.PkgName) ON tbl1.AcctType=tbl2.AcctType and tbl1.AcctName=tbl3.AcctName
WHERE AcctNum=parameter

I hope someone can help me with this.

2007-07-17 06:54:37 · 1 answers · asked by AJ 7 in Computers & Internet Programming & Design

1 answers

try using a outer join (see below) which selects all rows from parent table even if none exist in child table

Select tbl2.PkgName, tbl3.Cases FROM tbl1 INNER JOIN (tbl2 LEFT OUTER JOIN tbl3 ON tbl2.PkgName=tbl3.PkgName) ON tbl1.AcctType=tbl2.AcctType and tbl1.AcctName=tbl3.AcctName
WHERE AcctNum=parameter

2007-07-17 07:14:10 · answer #1 · answered by steve B 2 · 0 0

fedest.com, questions and answers