tags:

views:

137

answers:

1

Hey guys,

This really a question to concatinate multiple rows in to one when outputting:

I have three tables, table one (tableA) containing users data like name and email, another (tableB) flagging if they wish to receive an email or sms notice and a last table (tableC) noting which type of notices they require out of four types.

tableA and tableB have single rows for each user, but tableC could have up to 4 entries.

Is it possible I can concatinate the multiple entries of tableC in to a single row return, additionally with my other data from my other two tables. Perhaps building some sort of comma delimited field in the row?

I currently have this as my mySQL query:

SELECT
ppf.page_id,
prv.`name`,
prv.surname,
prv.email,
prv.mobile,
ppf.email,
ppf.sms,
page_profile_noticetypes.noticetype
FROM
page_registration_value AS prv
Inner Join page_profile_value AS ppf ON prv.page_id = ppf.user
Inner Join page_profile_noticetypes ON page_profile_noticetypes.page_id = ppf.page_id
WHERE ppf.sms = 1 OR ppf.email = 1

Here are some screen shots of what I get and then what I would love to have (or something similar)


What I get image


What I would like


Uber thanks.

A: 

@itsadok answered it - Result:

SELECT
ppf.page_id,
prv.`name`,
prv.surname,
prv.email,
prv.mobile,
ppf.email,
ppf.sms,
GROUP_CONCAT(page_profile_noticetypes.noticetype)
FROM
page_registration_value AS prv
Inner Join page_profile_value AS ppf ON prv.page_id = ppf.user
Inner Join page_profile_noticetypes ON page_profile_noticetypes.page_id = ppf.page_id
WHERE ppf.sms = 1 OR ppf.email = 1
GROUP BY prv.email
Glycerine