Mailing List Archive



Back to the month index Back to the list index

Jeanne Gold (goldj@Ix.netcom.com)
Mon, 07 Apr 1997 14:35:59 -0700


Message-Id: <1.5.4.32.19970407213559.006845f4@199.182.120.3>
Date: Mon, 07 Apr 1997 14:35:59 -0700
From: Jeanne Gold <goldj@Ix.netcom.com>
Subject: Re: [mSQL] n-n query

At 03:31 PM 4/7/97 +0200, you wrote:
>Hello,
>
>I would like to make a n-n query in my database :
>
> ___________ __________ ___________
>| | | | | |
>| Products |---| ProdSupp |----| Suppliers |
>|___________| |__________| |___________|
> ^ ^
> L _ _ _ _ _ _ _ _ _ _ _ _|
> (n,n)
>
>I have a ProdSup pivot table, and my query is like : "Give me the names
>of the
>suppliers where I can find Product number X" :
>
>=======================
>SELECT Suppliers.Name
>FROM Suppliers, ProdSupp, Products
>WHERE (ProdSupp.ProductID=234) AND (Suppliers.ID = ProdSupp.SupplierID)\g
>=======================
>(note that I tried different parenthesis combinations)
>

try this:
SELECT Suppliers.Name
FROM ProdSupp, Suppliers
WHERE (ProdSupp.ProductID = 234 ) AND (Suppliers.ID = ProdSupp.SupplierID)
\g

I don't see that there is any reason to be selecting from the "Products"
table as you are neither seeking against it (where...) nor showing any of
its info (Select ...). My guess is that you are running forever because you
are creating a situation where every single match in the where clause is
then being ADDED to every record in the PRODUCTS table.

Something like:
SELECT *
FROM TableA, TableB
\g

will produce number of records in TableA * number of records in TableB.

Jeanne
goldj@ix.netcom.com

--------------------------------------------------------------------------
To remove yourself from the Mini SQL mailing list send a message containing
"unsubscribe" to "unsubscribe" to msql-list-request@bunyip.com. Send a message containing
"info msql-list" to majordomo@bunyip.com for info on monthly archives of
the list. For more help, mail owner-msql-list@bunyip.com NOT the msql-list!