Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

LEFT JOIN question

Discussion in 'Information Technology' started by Access Sortof Newb, Jul 28, 2006.

  1. Access Sortof Newb

    Access Sortof Newb
    Expand Collapse
    Guest

    Good day all,

    I have four tables that I am attempting to LEFT JOIN together in a
    query:
    tblPartNumber (PartNumberID is primary key autonumber)
    tblPartNumberVendor (PartNumberVendorID is primary key autonumber)
    tblPartNumberSupplier (PartNumberSupplierID is primary key autonumber)
    tblPartNumberCost (PartNumberCostID is primary key autonumber)

    The relationships are as follows:
    tblPartNumber.PartNumberID--1-------many-->tblPartNumberVendor.PartNumberID
    tblPartNumberVendor.PartNumberVendorID--1------many-->tblPartNumberSupplier.PartNumberVendorID
    tblPartNumberSupplier.PartNumberSupplierID--1---many-->tblPartNumberCost.PartNumberSupplierID

    I attempted this SQL statement but was flagged for a syntax error:
    SELECT tblPartNumber.fldPartNumber,
    tblPartNumberVendor.fldPartNumberVendor,
    tblPartNumberSupplier.fldPartNumberSupplier
    FROM tblPartNumber LEFT JOIN tblPartNumberVendor ON
    (tblPartNumber.PartNumberID = tblPartNumberVendor.PartNumberID)
    LEFT JOIN tblPartNumberSupplier ON
    (tblPartNumberVendor.PartNumberVendorID =
    tblPartNumberSupplier.PartNumberVendorID)
    LEFT JOIN tblPartNumberCost ON
    (tblPartNumberSupplier.PartNumberSupplerID =
    tblPartNumberCost.PartNumberSupplierID);

    Should I change my relationships and have PartNumberID be related
    throughout all four tables?

    Thanks for the help
     
  2. Loading...

    Similar Threads Forum Date
    Sikh News How The Left & Indian Nationalists Distorted The History Of Sikh Gadhar Movement - Breaking News Sep 21, 2016
    SciTech Voyager 1 has left the solar system — almost Breaking News Mar 23, 2013
    General Right to Left all shades participated in March for Punjabi language Hard Talk Feb 25, 2013
    Heritage Priceless Belongings of Guru Gobind Singh Left to Decay in Neglected Forts History of Sikhism Feb 17, 2013
    Opinion Poll Pact: Left Wants 30 Seats From Ppp Punjab, Punjabi, Punjabiyat Aug 31, 2011

  3. Roger Carlson

    Roger Carlson
    Expand Collapse
    Guest

    Not if your relationships are as you describe them. What is the error?


    --
    --Roger Carlson
    MS Access MVP
    Access Database Samples: www.rogersaccesslibrary.com
    Want answers to your Access questions in your Email?
    Free subscription:
    http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


    "Access Sortof Newb" <tricard@gmail.com> wrote in message
    news:1151000444.304261.140650@m73g2000cwd.googlegroups.com...
    > Good day all,
    >
    > I have four tables that I am attempting to LEFT JOIN together in a
    > query:
    > tblPartNumber (PartNumberID is primary key autonumber)
    > tblPartNumberVendor (PartNumberVendorID is primary key autonumber)
    > tblPartNumberSupplier (PartNumberSupplierID is primary key autonumber)
    > tblPartNumberCost (PartNumberCostID is primary key autonumber)
    >
    > The relationships are as follows:
    >

    tblPartNumber.PartNumberID--1-------many-->tblPartNumberVendor.PartNumberID
    >

    tblPartNumberVendor.PartNumberVendorID--1------many-->tblPartNumberSupplier.
    PartNumberVendorID
    >

    tblPartNumberSupplier.PartNumberSupplierID--1---many-->tblPartNumberCost.Par
    tNumberSupplierID
    >
    > I attempted this SQL statement but was flagged for a syntax error:
    > SELECT tblPartNumber.fldPartNumber,
    > tblPartNumberVendor.fldPartNumberVendor,
    > tblPartNumberSupplier.fldPartNumberSupplier
    > FROM tblPartNumber LEFT JOIN tblPartNumberVendor ON
    > (tblPartNumber.PartNumberID = tblPartNumberVendor.PartNumberID)
    > LEFT JOIN tblPartNumberSupplier ON
    > (tblPartNumberVendor.PartNumberVendorID =
    > tblPartNumberSupplier.PartNumberVendorID)
    > LEFT JOIN tblPartNumberCost ON
    > (tblPartNumberSupplier.PartNumberSupplerID =
    > tblPartNumberCost.PartNumberSupplierID);
    >
    > Should I change my relationships and have PartNumberID be related
    > throughout all four tables?
    >
    > Thanks for the help
    >
     
  4. Rob Parker

    Rob Parker
    Expand Collapse
    Guest

    I suspect it's a problem with misplaced brackets. Also, there's an apparent
    typo in the second-last line (.PartNumberSupplerID should almost certainly
    be .PartNumberSupplierID - changed below). See if this gives what you want:

    SELECT tblPartNumber.fldPartNumber,
    tblPartNumberVendor.fldPartNumberVendor,
    tblPartNumberSupplier.fldPartNumberSupplier
    FROM ((tblPartNumber LEFT JOIN tblPartNumberVendor ON
    tblPartNumber.PartNumberID = tblPartNumberVendor.PartNumberID)
    LEFT JOIN tblPartNumberSupplier ON
    tblPartNumberVendor.PartNumberVendorID =
    tblPartNumberSupplier.PartNumberVendorID)
    LEFT JOIN tblPartNumberCost ON
    tblPartNumberSupplier.PartNumberSupplierID =
    tblPartNumberCost.PartNumberSupplierID;

    HTH,

    Rob

    "Access Sortof Newb" <tricard@gmail.com> wrote in message
    news:1151000444.304261.140650@m73g2000cwd.googlegroups.com...
    > Good day all,
    >
    > I have four tables that I am attempting to LEFT JOIN together in a
    > query:
    > tblPartNumber (PartNumberID is primary key autonumber)
    > tblPartNumberVendor (PartNumberVendorID is primary key autonumber)
    > tblPartNumberSupplier (PartNumberSupplierID is primary key autonumber)
    > tblPartNumberCost (PartNumberCostID is primary key autonumber)
    >
    > The relationships are as follows:
    > tblPartNumber.PartNumberID--1-------many-->tblPartNumberVendor.PartNumberID
    > tblPartNumberVendor.PartNumberVendorID--1------many-->tblPartNumberSupplier.PartNumberVendorID
    > tblPartNumberSupplier.PartNumberSupplierID--1---many-->tblPartNumberCost.PartNumberSupplierID
    >
    > I attempted this SQL statement but was flagged for a syntax error:
    > SELECT tblPartNumber.fldPartNumber,
    > tblPartNumberVendor.fldPartNumberVendor,
    > tblPartNumberSupplier.fldPartNumberSupplier
    > FROM tblPartNumber LEFT JOIN tblPartNumberVendor ON
    > (tblPartNumber.PartNumberID = tblPartNumberVendor.PartNumberID)
    > LEFT JOIN tblPartNumberSupplier ON
    > (tblPartNumberVendor.PartNumberVendorID =
    > tblPartNumberSupplier.PartNumberVendorID)
    > LEFT JOIN tblPartNumberCost ON
    > (tblPartNumberSupplier.PartNumberSupplerID =
    > tblPartNumberCost.PartNumberSupplierID);
    >
    > Should I change my relationships and have PartNumberID be related
    > throughout all four tables?
    >
    > Thanks for the help
    >
     
  5. Access Sortof Newb

    Access Sortof Newb
    Expand Collapse
    Guest

    Thanks Rob, that fixed the problem.

    Rob Parker wrote:
    > I suspect it's a problem with misplaced brackets. Also, there's an apparent
    > typo in the second-last line (.PartNumberSupplerID should almost certainly
    > be .PartNumberSupplierID - changed below). See if this gives what you want:
    >
    > SELECT tblPartNumber.fldPartNumber,
    > tblPartNumberVendor.fldPartNumberVendor,
    > tblPartNumberSupplier.fldPartNumberSupplier
    > FROM ((tblPartNumber LEFT JOIN tblPartNumberVendor ON
    > tblPartNumber.PartNumberID = tblPartNumberVendor.PartNumberID)
    > LEFT JOIN tblPartNumberSupplier ON
    > tblPartNumberVendor.PartNumberVendorID =
    > tblPartNumberSupplier.PartNumberVendorID)
    > LEFT JOIN tblPartNumberCost ON
    > tblPartNumberSupplier.PartNumberSupplierID =
    > tblPartNumberCost.PartNumberSupplierID;
    >
    > HTH,
    >
    > Rob
     

Share This Page