UsingĀ MySQL
, I can do something like:
SELECT book_title FROM book WHERE category_id = 3;
My Output:
java 7
java 8
java 11
but instead I just want 1 row, 1 col:
Expected Output:
java 7|java 8|java 11
Answer
You can useĀ GROUP_CONCAT
:
SELECT category_id ,
GROUP_CONCAT(book_title SEPARATOR '|')
FROM book
GROUP BY category_id;