Gunakan bergabung sendiri:
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 r1
INNER JOIN rooms AS r2 ON r1.HOTEL_ID=r2.HOTEL_ID
INNER JOIN rooms AS r3 ON r1.HOTEL_ID=r3.HOTEL_ID
WHERE r1.MAX_ADULTS=1
AND r2.MAX_ADULTS=2
AND r3.MAX_ADULTS=3
Anda harus menambahkan klausa untuk memeriksa masukkan jumlah kamar kondisi.
hasil_id yang dihasilkan akan menjadi r1.HOTEL_ID
.
Anda akan mendapatkan satu baris per hotel.