Welcome Guest, Not a member yet? Register   Sign In
Retrieving multiple emails addresses for single contact on table join
#1

[eluser]Andy UK[/eluser]
Hello all!

What's the best practice for retrieving multiple records from a second table on a join? I've just had to normalise customer emails into a separate table so I can permit multiple emails, select primary email, etc. Beforehand there was just a single email field in the contact table. I need to return all the email addresses for a contact when querying for the contact info.

I've read about a CONCAT function for MySQL that returns multiple values in a comma separated list. I guess another option would be to create a separate query to get the emails and run through that. For a single contact that should be easy as anything, whereas for a list of contacts I would have to loop through all the contacts, query the database each time for emails and add them to an array with a key equal to the contact id.

So those are the two ways i've come across. But since this must be such a common requirement, can anyone tell me what they consider to be the best way to do it?

Cheers!


Messages In This Thread
Retrieving multiple emails addresses for single contact on table join - by El Forum - 06-06-2014, 12:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB