Home All Groups Group Topic Archive Search About

Query to get a comma separated list of item2 grouped by item1

Author
9 Dec 2006 11:06 AM
Shocky
There is a table AuthorHeader

CREATE TABLE AuthorHeader
( AuthorID INT,
  AuthorName VARCHAR(50),
  BookTitle VARCHAR(100)
)

Sample Data in AuthorHeader
AuthorID      AuthorName           BookTitle
---------     ----------------     ------------
10001         A1                   BT11
10001         A1                   BT12
10001         A1                   BT13
10002         A2                   BT21
10003         A3                   BT31
10003         A3                   BT32

The result that i require from querying this table is author name and
the comma separated list of book titles that are written by him, as
shown below :

Author                    Books
-------                   -----------------------------
A1                        BT11,BT12,BT13
A2                        BT21
A3                        BT31,BT32

Can anyone please come up with the script!

AddThis Social Bookmark Button