MySQL Forums
Forum List  »  Newbie

Re: combine multiple rows from joined tables into single row
Posted by: Huu Da Tran
Date: October 01, 2008 08:41AM

If all people don't have the same amount of information, it's not really possible to create a "variable-column" row.

One way to go around this is to create something that would be easy to parse on your application side. Putting aside all the checkings, try something that would be like this:

select ...,
    group_concat(
        concat('<address type="', address_type_id, '">',
            '<address_1>', address_1, '</address_1>',
            '<otherfield>', otherfield, '</otherfield>',
            ...
        )
        SEPARATOR ";"
    )
FROM ...
GROUP BY p.person_id
Of course, you need something to indicate the nature of the address

Huu Da
MySQL flirter

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.