java - SQL query varchar concatenation when doing joins -



java - SQL query varchar concatenation when doing joins -

i'm writing webservice query info database , set jsonarray. have 1 table called client , table called client_notes holds date , notes client. there can multiple client_notes entries client, not other way around.

so query is:

select c.client_name, cn.note_date, cn.content client c left bring together client_notes cn on c.client_id = cn.client_id order c.client_name

currently, multiple rows per client if have multiple note entries.

how alter query 1 row per client , note_date content columns can combined concatenated string newline characters in between.

you grouping results , apply group_concat function:

select c.client_name, group_concat(cn.note_date separator '\n'), group_concat(date_format(cn.content, '%d-%m-%y') separator '\n') client c left bring together client_notes cn on c.client_id = cn.client_id grouping c.client_name order c.client_name

java mysql sql

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -