Hi,
I have two tables,
Table A has users' info, name, address.etc
Table B has notes that created by users in Table A, each user can create multiple notes.
Table A
userid
username
firstname
lastname
address
Table B
noteid
userid
note
date
I need to create an Excel report that contain all users and their notes. Since each user can create multiple notes, I want to combine individual user's notes into one cell. Is there a way to do this in SQL stored procedure? thanks
select
tableA.userid as `Id`,
tableA.username as `User`,
GROUP_CONCAT(tableB.note) as `Notes`
from
tableA,
tableB
where
tableA.userid=tableB.useri
group by
tableA.userid