Hiya,
I'm joining some tables ->
tbl_Author
AuthorID AuthorName
1 Potsy Mcabre
2 Jack Mckeown
3 Ian Swift
tbl_Books
BookID BookName
1 Five Go Fishin in Florida
2 How I learned to stop worryin and love the bomb
3 You can't clean a window with a spade
tbl_Author_Books_Linker
AuthorID BookID
1 1
1 2
1 3
My SQL statement:
select a.authorname, b.bookname from tbl_Author a
inner join
tbl_Author_Books_Linker c on c.authorID = a.authorID
inner join
tbl_Author_Books b on b.BookID = c.BookID
This works and gives me three results rows eg:
Potsy Macbre Five Go Fishin in Florida
Potsy Macbre How I learned to stop worryin and love the bomb
Potsy Macbre You can't clean a window with a spade
When I come to display the results, I only want to display the authors name once, but list the books they have written eg
Potsy Macbre
Five Go Fishin in Florida
How I learned to stop worryin and love the bomb
You can't clean a window with a spade
As I've got lots of authors in my table, I'm using:
while($row = mysql_fetch_array($result)){
//write out author results
//write book results
}
but as I said it prints out three results sets, and I only really want one results set per author containing all the books they have written.
I've tried using DISTINCT and GROUP by, but it's not giving the desired effect. Any ideas?
Cheers,
Stuart😕