Use a self join:
SELECT r1.HOTEL_ID, r1.MAX_ADULTS, r1.NO_OF_ROOMS, r2.MAX_ADULTS, r2.NO_OF_ROOMS, r3.MAX_ADULTS, r3.NO_OF_ROOMS,FROM rooms AS r1INNER JOIN rooms AS r2 ON r1.HOTEL_ID=r2.HOTEL_IDINNER JOIN rooms AS r3 ON r1.HOTEL_ID=r3.HOTEL_IDWHERE r1.MAX_ADULTS=1AND r2.MAX_ADULTS=2AND r3.MAX_ADULTS=3
You will have to add clauses to check the input number of rooms conditions.
The generated result_id would be r1.HOTEL_ID
.
You would get a single row per hotel.