Good day all,
I have a large outer joined query that I want to have some criteria.
The select query is gathering all part numbers from tblPartNumbers,
left joining to tblPartNumberVendor (since more than one vendor can
make the part), then left joining to tblPartNumberSupplier (since more
than one supplier can distribute the vendor's part), then left joining
to tblPartNumberCost (since more than one cost can be associated with a
single supplier if there are pricebreaks). Now, each of these have a
field named fldPrimary. I want to limit this join to only show the
primary vendor, primary supplier for the primary vendor and the primary
cost for the primary supplier, but if there is no entry for the part
number to still show the part number. Here is my current working SQL
statement:
SELECT tblPartNumber.PartNumberID, tblPartNumber.fldPartNumber,
tblPartNumber.fldDescription, tblPartNumberVendor.VendorID,
tblPartNumberVendor.fldPartNumberVendor,
tblPartNumberSupplier.SupplierID,
tblPartNumberSupplier.fldPartNumberSupplier,
tblPartNumberCost.fldUnits, tblPartNumberCost.fldCostCDN,
tblPartNumberCost.fldCostUS
FROM (tblPartNumber LEFT JOIN tblPartNumberVendor ON
tblPartNumber.PartNumberID = tblPartNumberVendor.PartNumberID) LEFT
JOIN (tblPartNumberSupplier LEFT JOIN tblPartNumberCost ON
tblPartNumberSupplier.PartNumberSupplierID =
tblPartNumberCost.PartNumberSupplierID) ON
tblPartNumberVendor.PartNumberVendorID =
tblPartNumberSupplier.PartNumberVendorID;
I tried adding AND criteria within each left join like this:
SELECT tblPartNumber.PartNumberID, tblPartNumber.fldPartNumber,
tblPartNumber.fldDescription, tblPartNumberVendor.VendorID,
tblPartNumberVendor.fldPartNumberVendor,
tblPartNumberSupplier.SupplierID,
tblPartNumberSupplier.fldPartNumberSupplier,
tblPartNumberCost.fldUnits, tblPartNumberCost.fldCostCDN,
tblPartNumberCost.fldCostUS
FROM (tblPartNumber LEFT JOIN tblPartNumberVendor ON
(tblPartNumber.PartNumberID = tblPartNumberVendor.PartNumberID AND
tblPartNumberVendor.fldPrimaryVendor = yes)) LEFT JOIN
(tblPartNumberSupplier LEFT JOIN tblPartNumberCost ON
(tblPartNumberSupplier.PartNumberSupplierID =
tblPartNumberCost.PartNumberSupplierID AND
tblPartNumberCost.fldPrimaryCost = yes)) ON
(tblPartNumberVendor.PartNumberVendorID =
tblPartNumberSupplier.PartNumberVendorID AND
tblPartNumberSupplier.fldPrimarySupplier = yes);
But this still only returned a full outer join on each. I also tried
adding the criteria to the WHERE clause, but this demoted the outer
joins to inner joins. is there any way I can do this outer join in
access?
Thanks for the help and the time
Tim 2 3119 tr*****@gmail.com wrote in
news:11**********************@c74g2000cwc.googlegr oups.com: Good day all,
I have a large outer joined query that I want to have some criteria. The select query is gathering all part numbers from tblPartNumbers, left joining to tblPartNumberVendor (since more than one vendor can make the part), then left joining to tblPartNumberSupplier (since more than one supplier can distribute the vendor's part), then left joining to tblPartNumberCost (since more than one cost can be associated with a single supplier if there are pricebreaks). Now, each of these have a field named fldPrimary. I want to limit this join to only show the primary vendor, primary supplier for the primary vendor and the primary cost for the primary supplier, but if there is no entry for the part number to still show the part number. Here is my current working SQL statement:
SELECT tblPartNumber.PartNumberID, tblPartNumber.fldPartNumber, tblPartNumber.fldDescription, tblPartNumberVendor.VendorID, tblPartNumberVendor.fldPartNumberVendor, tblPartNumberSupplier.SupplierID, tblPartNumberSupplier.fldPartNumberSupplier, tblPartNumberCost.fldUnits, tblPartNumberCost.fldCostCDN, tblPartNumberCost.fldCostUS FROM (tblPartNumber LEFT JOIN tblPartNumberVendor ON tblPartNumber.PartNumberID = tblPartNumberVendor.PartNumberID) LEFT JOIN (tblPartNumberSupplier LEFT JOIN tblPartNumberCost ON tblPartNumberSupplier.PartNumberSupplierID = tblPartNumberCost.PartNumberSupplierID) ON tblPartNumberVendor.PartNumberVendorID = tblPartNumberSupplier.PartNumberVendorID;
I tried adding AND criteria within each left join like this:
SELECT tblPartNumber.PartNumberID, tblPartNumber.fldPartNumber, tblPartNumber.fldDescription, tblPartNumberVendor.VendorID, tblPartNumberVendor.fldPartNumberVendor, tblPartNumberSupplier.SupplierID, tblPartNumberSupplier.fldPartNumberSupplier, tblPartNumberCost.fldUnits, tblPartNumberCost.fldCostCDN, tblPartNumberCost.fldCostUS FROM (tblPartNumber LEFT JOIN tblPartNumberVendor ON (tblPartNumber.PartNumberID = tblPartNumberVendor.PartNumberID AND tblPartNumberVendor.fldPrimaryVendor = yes)) LEFT JOIN (tblPartNumberSupplier LEFT JOIN tblPartNumberCost ON (tblPartNumberSupplier.PartNumberSupplierID = tblPartNumberCost.PartNumberSupplierID AND tblPartNumberCost.fldPrimaryCost = yes)) ON (tblPartNumberVendor.PartNumberVendorID = tblPartNumberSupplier.PartNumberVendorID AND tblPartNumberSupplier.fldPrimarySupplier = yes);
But this still only returned a full outer join on each. I also tried adding the criteria to the WHERE clause, but this demoted the outer joins to inner joins. is there any way I can do this outer join in access?
Thanks for the help and the time
Tim
Yes. You have to add the where clause to return where the field
is null. So starting from your first example
WHERE
(
tblPartNumberVendor.fldPrimary is TRUE
OR
tblPartNumberVendor.fldPrimary is NULL
)
AND
(
tblPartNumberSupplier.fld primary is TRUE
OR
tblPartNumberSupplier.fld primary is NULL
)
AND
(
tblPartNumberCost.fld primary is NULL
OR
tblPartNumberCost.fld primary is NULL
)
The nesting of OR inside AND is very important.
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com
Right On!! That did the trick. Thank you very much for the help
Tim
Bob Quintal wrote: tr*****@gmail.com wrote in news:11**********************@c74g2000cwc.googlegr oups.com:
Good day all,
I have a large outer joined query that I want to have some criteria. The select query is gathering all part numbers from tblPartNumbers, left joining to tblPartNumberVendor (since more than one vendor can make the part), then left joining to tblPartNumberSupplier (since more than one supplier can distribute the vendor's part), then left joining to tblPartNumberCost (since more than one cost can be associated with a single supplier if there are pricebreaks). Now, each of these have a field named fldPrimary. I want to limit this join to only show the primary vendor, primary supplier for the primary vendor and the primary cost for the primary supplier, but if there is no entry for the part number to still show the part number. Here is my current working SQL statement:
SELECT tblPartNumber.PartNumberID, tblPartNumber.fldPartNumber, tblPartNumber.fldDescription, tblPartNumberVendor.VendorID, tblPartNumberVendor.fldPartNumberVendor, tblPartNumberSupplier.SupplierID, tblPartNumberSupplier.fldPartNumberSupplier, tblPartNumberCost.fldUnits, tblPartNumberCost.fldCostCDN, tblPartNumberCost.fldCostUS FROM (tblPartNumber LEFT JOIN tblPartNumberVendor ON tblPartNumber.PartNumberID = tblPartNumberVendor.PartNumberID) LEFT JOIN (tblPartNumberSupplier LEFT JOIN tblPartNumberCost ON tblPartNumberSupplier.PartNumberSupplierID = tblPartNumberCost.PartNumberSupplierID) ON tblPartNumberVendor.PartNumberVendorID = tblPartNumberSupplier.PartNumberVendorID;
I tried adding AND criteria within each left join like this:
SELECT tblPartNumber.PartNumberID, tblPartNumber.fldPartNumber, tblPartNumber.fldDescription, tblPartNumberVendor.VendorID, tblPartNumberVendor.fldPartNumberVendor, tblPartNumberSupplier.SupplierID, tblPartNumberSupplier.fldPartNumberSupplier, tblPartNumberCost.fldUnits, tblPartNumberCost.fldCostCDN, tblPartNumberCost.fldCostUS FROM (tblPartNumber LEFT JOIN tblPartNumberVendor ON (tblPartNumber.PartNumberID = tblPartNumberVendor.PartNumberID AND tblPartNumberVendor.fldPrimaryVendor = yes)) LEFT JOIN (tblPartNumberSupplier LEFT JOIN tblPartNumberCost ON (tblPartNumberSupplier.PartNumberSupplierID = tblPartNumberCost.PartNumberSupplierID AND tblPartNumberCost.fldPrimaryCost = yes)) ON (tblPartNumberVendor.PartNumberVendorID = tblPartNumberSupplier.PartNumberVendorID AND tblPartNumberSupplier.fldPrimarySupplier = yes);
But this still only returned a full outer join on each. I also tried adding the criteria to the WHERE clause, but this demoted the outer joins to inner joins. is there any way I can do this outer join in access?
Thanks for the help and the time
Tim Yes. You have to add the where clause to return where the field is null. So starting from your first example
WHERE ( tblPartNumberVendor.fldPrimary is TRUE OR tblPartNumberVendor.fldPrimary is NULL ) AND ( tblPartNumberSupplier.fld primary is TRUE OR tblPartNumberSupplier.fld primary is NULL ) AND ( tblPartNumberCost.fld primary is NULL OR tblPartNumberCost.fld primary is NULL )
The nesting of OR inside AND is very important.
-- Bob Quintal
PA is y I've altered my email address.
-- Posted via a free Usenet account from http://www.teranews.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Marek Lewczuk |
last post by:
Hello,
I have a strange problem, maybe some of you will be able to explain me
something. I use LEFT JOIN as a substitute for subselects. It's true
that many subselects can be rewriten using LEFT...
|
by: Petre Agenbag |
last post by:
Hi List
Me again.
I'm trying to return from multiple tables, the records that have field
"information_sent" between two dates.
The tables are all related by means of the id of the entry in the...
|
by: Steve |
last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three
"Left Outer Joins" in order to return every transaction for a specific
set of criteria.
Using three "Left Outer Joins"...
|
by: Steve |
last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three
"Left Outer Joins" in order to return every transaction for a specific
set of criteria.
Using three "Left Outer Joins"...
|
by: Alan Lane |
last post by:
Hello world:
Background:
Yesterday, January 21, Doug Steele was kind enough to help me out on a Left
Join problem. I was trying to return all stores and their Gross Adds for
December, 2004...
|
by: Bob Alston |
last post by:
I am trying to use an access sql statement in a module that does a left
outer join on one table - joined to a table that has a selection
criteria. The result is an inner join.
If I do this in...
|
by: jason.evans |
last post by:
Hi there.
I am having an intrigueing problem.
I have a query which left joins another query to itself twice. The
original query is derived from a linked table in SQLServer 2000.
When I run...
|
by: aaron.reese |
last post by:
Guys,
this is my problem:-
I have records which are linked by two fields on a left inner join
(there may be 0,1 or more records in the right hand table)
The relationship is not unique (it's...
|
by: YZXIA |
last post by:
Is there any difference between explicit inner join and implicit
inner join
Example of an explicit inner join:
SELECT *
FROM employee
INNER JOIN department
ON employee.DepartmentID =...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |