I have some hotel with different hotel view for each room , and my end user when want 3 rooms for example each the room is 2 bed I have to combination the record for that , some times some fields may be duplicated and It's not important , and the user may have different room type in this situation I make example to each room have 2 bed number : I have problem when get result : I use self-join in "mysql" and all thing are true but some problem is have same row in this situation this is my code:
SELECT
table1.id,
table2.id,
table3.id,
table1.num_bed,
table2.num_bed,
table3.num_bed
LEFT JOIN
tour_package table2
ON table1.tour_id = table2.tour_id
AND table1.hotel_id = table2.hotel_id
AND table1.start_date = table2.start_date
LEFT JOIN
tour_package table3
ON table2.tour_id = table3.tour_id
AND table2.hotel_id = table3.hotel_id
AND table2.start_date = table3.start_date
WHERE
table1.num_bed = 2
AND table2.num_bed = 2
AND table3.num_bed = 2
the result is :
Please attention to id , the one is table1.id, two is table2.id and three is table3.id
In the result we have some result like :
1-2-1
1-1-2
and etc
I want to prevent this and have one of them , please help me