469,913 Members | 2,129 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,913 developers. It's quick & easy.

Problem with multiple joins.

Hi All Database Gurus,

I am trying to write code which will produce all the possible valid
queries, given tables and join information for tables.
Right now i am just trying to construct all the sequential joins.
eg. if i have 4 tables A, B, C, D and the join conditions are
A Inner join B,
B Inner Join C,
C Left Outer join D
then i am constructing joins as :
1. A IJ B IJ C LJ D
2. B IJ A IJ C LJ D
3. B IJ C IJ A LJ D
4. B IJ C LJ D IJ A
5. C IJ B IJ A LJ D
6. C IJ B LJ D IJ A
7. C LJ D IJ B IJ A
I am not placing any paranthesis to specify the join order. And many
of them are giving me same output.

Can anybody tell me how to detect the joins which will give the same
output ?

here in this case the number of combinations are 7 but for 8 tables i
am getting 420 combinations and many of them are same.

so please help me to reduce the number of combinations.

eagerly waiting for suggetions.

Thanking you.

Prem.
(pr*******@hotmail.com)
Jul 20 '05 #1
1 4443
Without knowing the DDL and the join conditions there isn't a simple answer.

For example, these two joins:

....
FROM A
LEFT JOIN B
ON A.x = B.x
INNER JOIN C
ON A.x = C.x
....
FROM A
LEFT JOIN B
ON A.x = B.x
INNER JOIN C
ON B.x = C.x

could produce very different results even though they contain the same
tables and joins in the same sequence.

--
David Portas
------------
Please reply only to the newsgroup
--
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Matt | last post: by
16 posts views Thread by Randy Harris | last post: by
2 posts views Thread by narendra vuradi | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.