I have a table apartment
as below
aid | aname
1 | dream home
2 | My hub
3 | Lake view
another table apartment_details
id | aid | bhk | size | facing
1 | 1 | 2 | 1200 | east
2 | 1 | 2 | 1200 | west
3 | 1 | 2 | 1000 | south
4 | 1 | 2 | 1000 | north
I have written the query as
SELECT distinct ap.aid, ap.aname, al.bhk, (select group_concat(distinct concat(al.bhk,'BHK - ',al.size)) from apartment_details as al where al.id = ap.aid) as details
When I tried to display details
using foreach I get the output as
2BHK - 1200
2BHK - 1200
2BHK - 1000
2BHK - 1000
In this query it is considering bhk, size, facing in distinct and the output obtained is based on facing. This looks something like I am displaying duplicate data or something the same data is repeating as there is no facing displayed. How can I display only distinct values based on bhk, size and not facing so that I get the output as
2BHK - 1200
2BHK - 1000
Can anyone help me in solving this issue? Thanks in advance