View Full Version : Creating one list from 3 columns


Hammy
12-10-2002, 02:41 PM
Hi all,

I have a table "Individual" that has 3 fields in it (listing personal traits) Trait1, Trait2, Trait3

The traits are a defined list drawn from another table (traitid, traitname) and the id is stored in the Individual Table.

My users want to be able to pull a query of traits either by person (simple) or grouped by trait, then list any person that has that trait in any of their 3 trait fields.

I am having a devil of a time coming up with a query that will essentially pull each trait field, then combine them all into one long column of traits with the individual id associated so that I can group my report on that ONE field, instead of 3 groupings (one for each trait field).

Anyone follow that, and have any suggestions?

TIA
Hammy

NOL
12-10-2002, 03:06 PM
Hi ,

Assuming i understood your question correctly , the following may work :)

select traitid, trait1 as Trait from Individual
union
select traitid, trait2 from Individual
union
select traitid, trait3 from Individual

Good Luck.

Gina.

Hammy
12-15-2002, 06:13 AM
Yep, little tweaking and it worked great!

Thanks so much!

Hammy