RE: Two Different Tables one Query



This is called a "Cartesian join".

"A cartesian join is a join of every row of one table to every row of
another table. This normally happens when no matching join columns are
specified. For example, if table A with 100 rows is joined with table B with
1000 rows, a cartesian join will return 100,000 rows! Something to be
avoided!'


A join can be in the FROM clause:

FROM Table1 INNER JOIN Table2 ON Table1.DealerID = Table2.DealerID;


or in the WHERE clause:

WHERE A1.store_name = A2.store_name


Note: A query must have at least (N-1) join conditions to prevent a
cartesian product.

Note 2: A Cartesian join is very cpu intensive, and is usually done by
mistake.


As a side note, you should use a naming convention. You have "Date" as s
field name, which is a reserved word in Access, a function and a command.
Also, "Date' is not very descriptive.... Date of what???


HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


"Love Buzz" wrote:

Hello all.

John has been helping on another issue related to this one. Here is the deal:

1.) When I start a new query and bring in one table everything works fine.
I am adding the number of items processed for a period of time by User ID.

2.) When I introduce another table that contains data about errors by User
ID, the total items processed for those Users with errors is greatly
exaggerated (while those without errors is correct).

3.) I have not connected the tables or used any fields from the second table
in my query.

What would be causing this? Thanks for your help. Here's my SQL for the
query:

SELECT [December 4].UserID, Sum([December 4].Items) AS SumOfItems
FROM [December 4], Errors
WHERE ((([December 4].Date) Between [Start Date] And [End Date]))
GROUP BY [December 4].UserID;

.



Relevant Pages

  • Re: Editing disabled by alternative to INNER JOIN
    ... uses a Cartesian Join, ... A query that uses a Cartesian Join is not ... if you remove the WHERE clause in both queries and then ... This quote from Microsoft Jet Database Engine Programmer's Guide dates ...
    (comp.databases.ms-access)
  • Re: Editing disabled by alternative to INNER JOIN
    ... uses a Cartesian Join, ... A query that uses a Cartesian Join is not ... if you remove the WHERE clause in both queries and then ... This quote from Microsoft Jet Database Engine Programmer's Guide dates ...
    (comp.databases.ms-access)
  • Re: Find unmached records / create table
    ... I am struggling to understand how the Cartesian join works and what ... excatly is happening when the second query is run... ... > and CheckOutDate, so don't worry too much about the other columns. ... > FROM tblCheckOuts) AS Q ...
    (microsoft.public.access.queries)
  • Re: Join expression not supported with outer joins
    ... OK, it's a Cartesian join, but apparently a deliberate one. ... The problem goes away if I change the outer joins to inner ... Products INNER JOIN Suppliers ON Products.SupplierID = ... a single query that can be handed off to Crystal Reports. ...
    (microsoft.public.access.queries)
  • Re: Strange results
    ... Read much...I already posted the correct query. ... Charles Hooper wrote: ... Isn't a Cartesian join where you join one table to another where there ...
    (comp.databases.oracle.server)