3 table join even if not exist

  • I'm a newer user, so sorry if this is a pretty basic question!

    I have three transaction level tables representing three different stages of a product (A: standard 'BOM', B: estimated 'BOM', and C: actual 'BOM'). Each table contains item identification and quantity information on each line. The "common" field between them (and back to the main table) is ItemNo. I'm looking to build a view of the transactional details.

    No problems using a JOIN to link the header & each transaction table, but only one at a time... The difficulty is the three tables don't necessarily have corresponding data (eg: A & B have items 1234 & 1235, but C has item 1232 & 1235). I want to have the information for each item from each transaction table and report qty as NULL if the item isn't in the particular table.

    The end result I'm looking for is something like this:

    ItemNo A qty B qty C qty

    ------- ------ ------ ------

    1232 NULL NULL 12

    1234 5 6 NULL

    1235 7 8 8

  • select t.ItemNo, a.qty, b.qty, c.qty from

    (select ItemNo from TableA union select ItemNo from TableB union select ItemNo from TableC) t

    left outer join TableA a on t.ItemNo = a.ItemNo

    left outer join TableB b on t.ItemNo = b.ItemNo

    left outer join TableC c on t.ItemNo = c.ItemNo

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • Or, if you can use your main table, it can be even simpler...

    select t.ItemNo, a.qty, b.qty, c.qty from

    MainTable t

    left outer join TableA a on t.ItemNo = a.ItemNo

    left outer join TableB b on t.ItemNo = b.ItemNo

    left outer join TableC c on t.ItemNo = c.ItemNo

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • Thanks for the quick reply. I'll give the UNION a try.

  • RyanRandall (7/22/2008)


    select t.ItemNo, a.qty, b.qty, c.qty from

    (select ItemNo from TableA union select ItemNo from TableB union select ItemNo from TableC) t

    left outer join TableA a on t.ItemNo = a.ItemNo

    left outer join TableB b on t.ItemNo = b.ItemNo

    left outer join TableC c on t.ItemNo = c.ItemNo

    I think we're close... thanks for the help!

    My ItemNo is actually two concatenated fields (ItemNo + BatchNo)... when I run the 'from' select statement it populates wonderfully, but has no column name... So either need to build a column name or specify a blank column in the JOIN.

  • Neither. Do a 2 column join

    select t.ItemNo, t.BatchNo, a.qty, b.qty, c.qty from

    (select ItemNo, BatchNo from TableA union select ItemNo, BatchNo from TableB union select ItemNo, BatchNo from TableC) t

    left outer join TableA a on t.ItemNo = a.ItemNo and t.BatchNo = a.BatchNo

    left outer join TableB b on t.ItemNo = b.ItemNo and t.BatchNo = b.BatchNo

    left outer join TableC c on t.ItemNo = c.ItemNo and t.BatchNo = c.BatchNo

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Perfect! Thanks!

  • That's what I get for trying to keep the thread simple...

    In reality ItemID & BatchID aren't the link back to the main table, though it is the linking column between tables (though it's not always present). Tables A & B have a ProdID column link back to the main table and C has a CodeID column back to the main table.

    I swapped out the various column names and instead of 19 lines that I should get (16 common between all 3, and 3 that are hit and miss), I actually get >4500 rows of various combinations...

    What I'm thinking is building a separate view combining the transaction tables and using another view to pull the header table and add the transacation level view. I'm sure there's a better route to go.

  • Please post the full table definitions (as Create statements) and the query that you have now.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Actually, what you want is the rarely seen "FULL" Outer Join:

    select t.ItemNo, t.BatchNo, a.qty, b.qty, c.qty

    From TableA a

    Full outer join TableB b on a.ItemNo = b.ItemNo and a.BatchNo = b.BatchNo

    Full outer join TableC c on (a.ItemNo = c.ItemNo and a.BatchNo = c.BatchNo)

    OR (b.ItemNo = c.ItemNo and b.BatchNo = c.BatchNo )

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • I'll take a look at the FULL OUTER JOIN...

    Here's the answer to Gail's question (not a small amount of stuff):

    PRODBOM table:

    CREATE TABLE [dbo].[PRODBOM](

    [PRODID] [varchar](20) NOT NULL DEFAULT (''),

    [LINENUM] [numeric](28, 12) NOT NULL DEFAULT (0),

    [PRODLINETYPE] [int] NOT NULL DEFAULT (0),

    [BOMCONSUMP] [int] NOT NULL DEFAULT (0),

    [ITEMID] [varchar](20) NOT NULL DEFAULT (''),

    [BOMQTY] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DIM1] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DIM2] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DIM3] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DIM4] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DIM5] [numeric](28, 12) NOT NULL DEFAULT (0),

    [ROUNDUP] [int] NOT NULL DEFAULT (0),

    [ROUNDUPQTY] [numeric](28, 12) NOT NULL DEFAULT (0),

    [POSITION] [varchar](30) NOT NULL DEFAULT (''),

    [QTYBOMCALC] [numeric](28, 12) NOT NULL DEFAULT (0),

    [REMAINBOMPHYSICAL] [numeric](28, 12) NOT NULL DEFAULT (0),

    [REMAINBOMFINANCIAL] [numeric](28, 12) NOT NULL DEFAULT (0),

    [QTYINVENTCALC] [numeric](28, 12) NOT NULL DEFAULT (0),

    [RESERVATION] [int] NOT NULL DEFAULT (0),

    [INVENTTRANSID] [varchar](20) NOT NULL DEFAULT (''),

    [RAWMATERIALDATE] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [REMAININVENTPHYSICAL] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DIMENSION] [varchar](10) NOT NULL DEFAULT (''),

    [DIMENSION2_] [varchar](10) NOT NULL DEFAULT (''),

    [DIMENSION3_] [varchar](10) NOT NULL DEFAULT (''),

    [INVENTREFTYPE] [int] NOT NULL DEFAULT (0),

    [INVENTREFID] [varchar](20) NOT NULL DEFAULT (''),

    [INVENTREFTRANSID] [varchar](20) NOT NULL DEFAULT (''),

    [VENDID] [varchar](10) NOT NULL DEFAULT (''),

    [UNITID] [varchar](10) NOT NULL DEFAULT (''),

    [BACKORDERSTATUS] [int] NOT NULL DEFAULT (0),

    [CALCULATION] [int] NOT NULL DEFAULT (0),

    [QTYINVENTSTUP] [numeric](28, 12) NOT NULL DEFAULT (0),

    [QTYBOMSTUP] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DEL_SCRAPTYPEID] [varchar](10) NOT NULL DEFAULT (''),

    [BOMID] [varchar](20) NOT NULL DEFAULT (''),

    [FORMULA] [int] NOT NULL DEFAULT (0),

    [DEL_CONFIGID] [varchar](10) NOT NULL DEFAULT (''),

    [BOMREFRECID] [int] NOT NULL DEFAULT (0),

    [BOMQTYSERIE] [numeric](28, 12) NOT NULL DEFAULT (0),

    [ITEMBOMID] [varchar](20) NOT NULL DEFAULT (''),

    [INVENTDIMID] [varchar](20) NOT NULL DEFAULT (''),

    [REQPOID] [varchar](20) NOT NULL DEFAULT (''),

    [REQPLANIDSCHED] [varchar](10) NOT NULL DEFAULT (''),

    [SCRAPVAR] [numeric](28, 12) NOT NULL DEFAULT (0),

    [SCRAPCONST] [numeric](28, 12) NOT NULL DEFAULT (0),

    [CONSTANTRELEASED] [int] NOT NULL DEFAULT (0),

    [DATAAREAID] [varchar](3) NOT NULL DEFAULT ('dat'),

    [RECID] [int] NOT NULL,

    [DIMENSION4_] [varchar](10) NOT NULL DEFAULT (''),

    [OPRNUM] [int] NOT NULL DEFAULT (0),

    [ITEMROUTEID] [varchar](20) NOT NULL DEFAULT (''),

    [RecVersion] [int] NULL DEFAULT (1),

    CONSTRAINT [I_232TRANSIDIDX] PRIMARY KEY NONCLUSTERED

    (

    [DATAAREAID] ASC,

    [INVENTTRANSID] ASC

    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]

    ) ON [PRIMARY]

    PRODJOURNALBOM table:

    CREATE TABLE [dbo].[PRODJOURNALBOM](

    [JOURNALID] [varchar](10) NOT NULL DEFAULT (''),

    [VOUCHER] [varchar](20) NOT NULL DEFAULT (''),

    [LINENUM] [numeric](28, 12) NOT NULL DEFAULT (0),

    [PRODID] [varchar](20) NOT NULL DEFAULT (''),

    [TRANSDATE] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [ITEMID] [varchar](20) NOT NULL DEFAULT (''),

    [INVENTTRANSID] [varchar](20) NOT NULL DEFAULT (''),

    [POSITION] [varchar](30) NOT NULL DEFAULT (''),

    [INVENTCONSUMP] [numeric](28, 12) NOT NULL DEFAULT (0),

    [BOMCONSUMP] [numeric](28, 12) NOT NULL DEFAULT (0),

    [BOMUNITID] [varchar](10) NOT NULL DEFAULT (''),

    [INVENTPROPOSAL] [numeric](28, 12) NOT NULL DEFAULT (0),

    [BOMPROPOSAL] [numeric](28, 12) NOT NULL DEFAULT (0),

    [BOMSCRAP] [numeric](28, 12) NOT NULL DEFAULT (0),

    [ERRORCAUSE] [int] NOT NULL DEFAULT (0),

    [DIMENSION] [varchar](10) NOT NULL DEFAULT (''),

    [DIMENSION2_] [varchar](10) NOT NULL DEFAULT (''),

    [DIMENSION3_] [varchar](10) NOT NULL DEFAULT (''),

    [DIMENSION4_] [varchar](10) NOT NULL DEFAULT (''),

    [DEL_POSTED] [int] NOT NULL DEFAULT (0),

    [DEL_LOG] [varchar](255) NOT NULL DEFAULT (''),

    [ENDCONSUMP] [int] NOT NULL DEFAULT (0),

    [DEL_CONFIGID] [varchar](10) NOT NULL DEFAULT (''),

    [INVENTDIMID] [varchar](20) NOT NULL DEFAULT (''),

    [INVENTTRANSCHILDREFID] [varchar](20) NOT NULL DEFAULT (''),

    [INVENTTRANSCHILDTYPE] [int] NOT NULL DEFAULT (0),

    [INVENTRETURNFLAG] [int] NOT NULL DEFAULT (0),

    [INVENTCONTROLPROPOSAL] [int] NOT NULL DEFAULT (0),

    [DATAAREAID] [varchar](3) NOT NULL DEFAULT ('dat'),

    [RECID] [int] NOT NULL,

    [OPRNUM] [int] NOT NULL DEFAULT (0),

    [RecVersion] [int] NULL DEFAULT (1),

    CONSTRAINT [I_239LINEIDX] PRIMARY KEY CLUSTERED

    (

    [DATAAREAID] ASC,

    [JOURNALID] ASC,

    [LINENUM] ASC

    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]

    ) ON [PRIMARY]

    PRODTABLE table:

    CREATE TABLE [dbo].[PRODTABLE](

    [ITEMID] [varchar](20) NOT NULL DEFAULT (''),

    [NAME] [varchar](60) NOT NULL DEFAULT (''),

    [PRODGROUPID] [varchar](10) NOT NULL DEFAULT (''),

    [PRODSTATUS] [int] NOT NULL DEFAULT (0),

    [PRODPRIO] [int] NOT NULL DEFAULT (0),

    [PRODLOCKED] [int] NOT NULL DEFAULT (0),

    [PRODTYPE] [int] NOT NULL DEFAULT (0),

    [SCHEDDATE] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [QTYSCHED] [numeric](28, 12) NOT NULL DEFAULT (0),

    [QTYSTUP] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DLVDATE] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [STUPDATE] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [FINISHEDDATE] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [SCHEDSTART] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [SCHEDEND] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [HEIGHT] [numeric](28, 12) NOT NULL DEFAULT (0),

    [WIDTH] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DEPTH] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DENSITY] [numeric](28, 12) NOT NULL DEFAULT (0),

    [QTYCALC] [numeric](28, 12) NOT NULL DEFAULT (0),

    [REALDATE] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [RESERVATION] [int] NOT NULL DEFAULT (0),

    [PRODPOSTINGTYPE] [int] NOT NULL DEFAULT (0),

    [INVENTTRANSID] [varchar](20) NOT NULL DEFAULT (''),

    [DIMENSION] [varchar](10) NOT NULL DEFAULT (''),

    [DIMENSION2_] [varchar](10) NOT NULL DEFAULT (''),

    [DIMENSION3_] [varchar](10) NOT NULL DEFAULT (''),

    [DIMENSION4_] [varchar](10) NOT NULL DEFAULT (''),

    [INVENTREFTYPE] [int] NOT NULL DEFAULT (0),

    [INVENTREFID] [varchar](20) NOT NULL DEFAULT (''),

    [INVENTREFTRANSID] [varchar](20) NOT NULL DEFAULT (''),

    [COLLECTREFLEVEL] [int] NOT NULL DEFAULT (0),

    [COLLECTREFPRODID] [varchar](20) NOT NULL DEFAULT (''),

    [BOMDATE] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [BACKORDERSTATUS] [int] NOT NULL DEFAULT (0),

    [PRODPOOLID] [varchar](10) NOT NULL DEFAULT (''),

    [PROFITSET] [int] NOT NULL DEFAULT (0),

    [CALCDATE] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [CHECKROUTE] [int] NOT NULL DEFAULT (0),

    [REMAININVENTPHYSICAL] [numeric](28, 12) NOT NULL DEFAULT (0),

    [BOMID] [varchar](20) NOT NULL DEFAULT (''),

    [ROUTEID] [varchar](20) NOT NULL DEFAULT (''),

    [DEL_CONFIGID] [varchar](10) NOT NULL DEFAULT (''),

    [REQPLANIDSCHED] [varchar](10) NOT NULL DEFAULT (''),

    [REQPOID] [varchar](20) NOT NULL DEFAULT (''),

    [REFLOOKUP] [int] NOT NULL DEFAULT (0),

    [LATESTSCHEDDIRECTION] [int] NOT NULL DEFAULT (0),

    [LATESTSCHEDDATE] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [PRODID] [varchar](20) NOT NULL DEFAULT (''),

    [INVENTDIMID] [varchar](20) NOT NULL DEFAULT (''),

    [PRODORIGID] [varchar](20) NOT NULL DEFAULT (''),

    [SHIFTNAME] [varchar](10) NOT NULL DEFAULT (''),

    [MACHINENAME] [varchar](10) NOT NULL DEFAULT (''),

    [CREATEDDATE] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [CREATEDTIME] [int] NOT NULL DEFAULT (0),

    [CREATEDBY] [varchar](5) NOT NULL DEFAULT ('?'),

    [DATAAREAID] [varchar](3) NOT NULL DEFAULT ('dat'),

    [RECVERSION] [int] NOT NULL DEFAULT (1),

    [RECID] [int] NOT NULL,

    CONSTRAINT [I_262PRODIDX] PRIMARY KEY CLUSTERED

    (

    [DATAAREAID] ASC,

    [PRODID] ASC

    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]

    ) ON [PRIMARY]

    BOM table:

    CREATE TABLE [dbo].[BOM](

    [LINENUM] [numeric](28, 12) NOT NULL DEFAULT (0),

    [BOMTYPE] [int] NOT NULL DEFAULT (0),

    [BOMCONSUMP] [int] NOT NULL DEFAULT (0),

    [ITEMID] [varchar](20) NOT NULL DEFAULT (''),

    [DEL_INVENTLOCATIONID] [varchar](10) NOT NULL DEFAULT (''),

    [BOMQTY] [numeric](28, 12) NOT NULL DEFAULT (0),

    [CALCULATION] [int] NOT NULL DEFAULT (0),

    [DIM1] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DIM2] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DIM3] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DIM4] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DIM5] [numeric](28, 12) NOT NULL DEFAULT (0),

    [ROUNDUP] [int] NOT NULL DEFAULT (0),

    [ROUNDUPQTY] [numeric](28, 12) NOT NULL DEFAULT (0),

    [POSITION] [varchar](30) NOT NULL DEFAULT (''),

    [FROMDATE] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [TODATE] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [DEL_SCRAPTYPEID] [varchar](10) NOT NULL DEFAULT (''),

    [VENDID] [varchar](10) NOT NULL DEFAULT (''),

    [UNITID] [varchar](10) NOT NULL DEFAULT (''),

    [BOMID] [varchar](20) NOT NULL DEFAULT (''),

    [CONFIGGROUPID] [varchar](10) NOT NULL DEFAULT (''),

    [FORMULA] [int] NOT NULL DEFAULT (0),

    [DEL_CONFIGID] [varchar](10) NOT NULL DEFAULT (''),

    [BOMQTYSERIE] [numeric](28, 12) NOT NULL DEFAULT (0),

    [ITEMBOMID] [varchar](20) NOT NULL DEFAULT (''),

    [INVENTDIMID] [varchar](20) NOT NULL DEFAULT (''),

    [SCRAPVAR] [numeric](28, 12) NOT NULL DEFAULT (0),

    [SCRAPCONST] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DATAAREAID] [varchar](3) NOT NULL DEFAULT ('dat'),

    [RECID] [int] NOT NULL,

    [OPRNUM] [int] NOT NULL DEFAULT (0),

    [ITEMROUTEID] [varchar](20) NOT NULL DEFAULT (''),

    [RecVersion] [int] NULL DEFAULT (1)

    ) ON [PRIMARY]

    PRODTABLEJOUR table:

    CREATE TABLE [dbo].[PRODTABLEJOUR](

    [PRODID] [varchar](20) NOT NULL DEFAULT (''),

    [ITEMID] [varchar](20) NOT NULL DEFAULT (''),

    [INVENTTRANSID] [varchar](20) NOT NULL DEFAULT (''),

    [TRANSDATE] [datetime] NOT NULL DEFAULT ('1900-01-01 00:00:00.000'),

    [JOURNALTYPE] [int] NOT NULL DEFAULT (0),

    [QTYGOOD] [numeric](28, 12) NOT NULL DEFAULT (0),

    [VOUCHER] [varchar](20) NOT NULL DEFAULT (''),

    [AMOUNTFINANCIAL] [numeric](28, 12) NOT NULL DEFAULT (0),

    [ADJUSTMENT] [numeric](28, 12) NOT NULL DEFAULT (0),

    [QTYERROR] [numeric](28, 12) NOT NULL DEFAULT (0),

    [DEL_CONFIGID] [varchar](10) NOT NULL DEFAULT (''),

    [AMOUNTPHYSICAL] [numeric](28, 12) NOT NULL DEFAULT (0),

    [SCRAPVOUCHER] [varchar](20) NOT NULL DEFAULT (''),

    [DATAAREAID] [varchar](3) NOT NULL DEFAULT ('dat'),

    [RECID] [int] NOT NULL,

    [RecVersion] [int] NULL DEFAULT (1)

    ) ON [PRIMARY]

    Select statement:

    SELECT

    LTRIM(RTRIM(d.PRODID)) AS ProdOrderID,

    d.BOMID AS BOMID,

    d.DIMENSION AS dim1Id,

    d.DIMENSION2_ AS dim2Id,

    d.DIMENSION3_ AS dim3Id,

    d.DIMENSION4_ AS dim4Id,

    d.ITEMID AS ProductID,

    RTRIM(LTRIM(d.INVENTDIMID)) as InventDimId,

    CAST(e.QTYGOOD AS VARCHAR) AS QtyGood,

    CAST(e.QTYERROR AS VARCHAR) AS QtyError,

    a.ITEMID as Est_ComponentItemID,

    a.INVENTDIMID AS Est_InventDimID,

    CAST(a.BOMQTY AS VARCHAR) AS Est_BOMQtyPer,

    CAST(a.QTYINVENTCALC AS VARCHAR) AS Est_QtyInventEst,

    CAST(a.QTYINVENTSTUP AS VARCHAR) AS Est_QtyInventStart,

    b.ITEMID AS Act_ComponentItemID,

    b.INVENTDIMID AS Act_InventDimID,

    b.TRANSDATE AS Act_TransDate,

    b.TRANSDATE AS TransDate,

    CAST(b.INVENTCONSUMP AS VARCHAR) AS Act_InventConsump,

    CAST(b.INVENTPROPOSAL AS VARCHAR) AS Act_InventProposal,

    c.ITEMID AS Std_ComponentItemID,

    c.INVENTDIMID AS Std_InventDimID,

    CAST(c.BOMQTY AS VARCHAR) AS Std_BOMQty

    FROM dbo.PRODTABLE d --FROM (select ITEMID, INVENTDIMID from PRODBOM union select ITEMID, INVENTDIMID from PRODJOURNALBOM union select ITEMID, INVENTDIMID from BOM) d

    FULL OUTER JOIN dbo.PRODBOM a ON d.PRODID = a.PRODID

    AND d.DATAAREAID = a.DATAAREAID

    FULL OUTER JOIN dbo.PRODJOURNALBOM b ON d.PRODID = b.PRODID

    AND d.DATAAREAID = b.DATAAREAID

    FULL OUTER JOIN dbo.BOM c ON d.BOMID = c.BOMID

    AND d.DATAAREAID = c.DATAAREAID

    FULL OUTER JOIN dbo.PRODTABLEJOUR e ON d.PRODID = e.PRODID

    AND d.ITEMID = e.PRODID

    AND d.DATAAREAID = e.DATAAREAID

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply