By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,130 Members | 2,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,130 IT Pros & Developers. It's quick & easy.

Problem with multiple joins.

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.