Or :
Main Topics
Browse All TopicsHi all,
I have a web based search using PHP and MySQL. I'll use three simplified tables and an example query. The Job table is a list of current and historical jobs performed. The Contacts table lists all of the contacts associated with a job, employees and external contacts like clients or consultants. The Person table is basically an "Address Book" type of table with contact info. Below are the fields in each table that are used in the query. The tables are existing and cannot be altered.
Job table:
Index (unique ID)
Number
Name
Job_Contact table:
Job_Index (joins to Job table)
Contact_ID (joins to Person table)
Role (defines role of contact - General Contractor, Owner, Consultant, etc.)
Title (function performed on the job, not necessarily the person's current job title)
Person table:
Contact_ID (unique ID)
Person_Name
Job_Title (person's current job title)
The Job_Contact.Title field and the Person.Job_Title field aren't necessarily equal. When someone performs the same duty as their job title, the Job_Contact.Title field is left blank. When they perform a duty other than their job title, that duty gets written into the Job_Contact.Title field for that specific job index and this should supercede the Person.Job_Title field in the returned results. One of the purposes of the query is to be able to find out who did what on a specific job or to find all the jobs where a specific person performed a certain duty.
I'll attach the query and example tables in case they may be useful.
Currently the query returns something like the following when searching for job number 2009002. John, Sue and Bob all performed the duties of "Project Manager" at some point during the job.
Number | Name| Project Manager
2009002 | Apex | John, Sue
2009002 | Apex | John, Bob
I'd like to be able to return something like:
Number | Name | Project Manager
__________________________
2009002 | Apex | John, Sue, Bob
I'd like to handle it on the database side rather than scripting if possible. Thank you in advance for any help.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thanks a lot. That worked perfectly. I made one minor tweek. I moved the GROUP_CONCAT inside the main CONCAT function so that it wouldn't duplicate the contact.`Title` result.
CONCAT(IF(contact_PM.`Cont
Thanks again, leakim971!
Business Accounts
Answer for Membership
by: leakim971Posted on 2009-10-30 at 14:30:37ID: 25706940
Hello foxymoron7,
Try something like :
Select allOpen in new window