I want to get multiple values in a single row which matches with primary table. Below are the example tables:
members:
- id
- name
- status
address:
- id
- ref_id(member id)
- address1
- state
contacts:
- id
- ref_id(member id)
- phone
- email
mem_cc
- id
- ref_id(member id)
- category_id
- coverage_id
I'm using below query to create view to get all the records in single view so I can query that view to display a list page:
SELECT a.id, a.name, a.status, b.address1, b.state, c.phone, d.category_id, d.coverage_id
FROM members a LEFT JOIN address b
ON a.id = b.ref_id
LEFT JOIN contacts c
ON a.id = c.ref_id
LEFT JOIN mem_cc d
ON a.id = d.ref_id
Now case like Member A is subscribed with 3 coverages or 3 categories then it'll show me Member A's record three times, I want to get Member A record in table single time with covering all categories and coverages in that single row. Question is how to do that?