Exploding information to flatness

From: Todd Benson <toddb_at_spectralogic.com>
Date: 18 Apr 2002 15:37:04 -0700
Message-ID: <97b61782.0204181437.319678bb_at_posting.google.com>



Is there an acceptable way to 'blow' out information into a flat file from tables that are related? In this particular case, I'm trying to move related data from tables to an Excel spreadsheet. Here would be a simplified example:

create table user (
  id int primary key,
  name varchar(50)
)

create table group (
  id int primary key,
  name varchar(50)
)

create table member (
  user int,
  group int,
    primary key( user, group )
)

Obviously, 'user' to 'group' is a many-many relationship.

I want to rotate out the groups into 'apparent' attributes for each user row in the spreadsheet. In other words, I want my rows from my select statement to look like this with 4 to n columns:

user.name group[1].name group[2].name group[3].name ...

where group[1], group[2], and group[3] are columns for all the groups that exist, but will have values of NULL for which the user is not a member.

Anyone have experience with this?

Thanks,
Todd Received on Fri Apr 19 2002 - 00:37:04 CEST

Original text of this message