Welcome to SPN

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

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

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
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page