Click to See Complete Forum and Search --> : Another SQL Question


abkkn
August 15th, 2003, 01:11 AM
Hello,

I have the following table,

[ id ] [ name ]
[ 1 ] [ A ]
[ 1 ] [ B ]
[ 2 ] [ B ]
[ 3 ] [ C ]
[ 3 ] [ D ]
[ 4 ] [ A ]
[ 4 ] [ D ]

I want to get the following output, is it possible?

[ id ] [ list ]
[ 1 ] [ A, B ]
[ 2 ] [ B ]
[ 3 ] [ C, D ]
[ 4 ] [ A, D ]

Thanks in advance,

abkkn.

womalley
August 15th, 2003, 09:14 AM
Originally posted by abkkn
Hello,

I have the following table,

[ id ] [ name ]
[ 1 ] [ A ]
[ 1 ] [ B ]
[ 2 ] [ B ]
[ 3 ] [ C ]
[ 3 ] [ D ]
[ 4 ] [ A ]
[ 4 ] [ D ]

I want to get the following output, is it possible?

[ id ] [ list ]
[ 1 ] [ A, B ]
[ 2 ] [ B ]
[ 3 ] [ C, D ]
[ 4 ] [ A, D ]

Thanks in advance,

abkkn.
Rather then do the INNER JOIN that I showed you, try doing an OUTER JOIN

In short
Lets say I have 2 tables A and B
I want all the records from B where the ForeignID of B = PrimaryID of A

Select A.Col1, A.Col2, B.Col1, B.Col2 FROM A RIGHT OUTER JOIN B ON B.ForeignID = A.PriamryID

this should get you close to what you want... I think

Will