Re: Algorithm for writing joins in SQL

From: sello <sello_at_operamail.com>
Date: 26 Jun 2003 21:43:45 -0700
Message-ID: <c97b9fa.0306262043.44db5518_at_posting.google.com>


sello_at_operamail.com (sello) wrote:
> Hi, I have a reporting application that needs to dynamically generate
> the sql query based on conditions & sorting. The underlying database
> is a simple star structure with inner joins between tables only.
>
> I need to be able to create the nested inner join syntax as is done in
> SQL server and MS Access query builders.

Think I've figured it...
Since the query is to return the intersect of all sets it doesn't matter in which order the tables are joined as long as they are all included.
A n B n C = A n (B n C) = (B n A) n C with appropriate conditions applied to each intersection.

Loop through the list of tables adding each one to the joined set when it relates to a table already in the joined set. Continue looping though tables until either they are all included in the joined set or can't be included, ie not related. Received on Fri Jun 27 2003 - 06:43:45 CEST

Original text of this message