I have a table of books.
I can select all the books for a certain author:
SELECT BookID FROM tblBook WHERE AuthorID=9
(returns 4 records):
23
63
85
98
But what if I want to return a single record, with the ID numbers concatenated like this:
23 63 开发者_JAVA技巧85 98
How do I do that?
Using MySQL.
SELECT group_concat(BookID SEPARATOR ' ') FROM tblBook WHERE AuthorID=9 GROUP BY BookID
check out the group_concat function.
精彩评论