0

This is an extension of my previous question. I have a query of inner joining 3 tables. (Actually self joining of the same table).

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

Now I don't want to join them all at every time. I want to join these 3 tables according to a input request by ignoring one or two joins at a time. Can it be done by changing this query itself. (If possible it's better)

Or I have to do it by applying the logic in the code.

Community
  • 1
  • 1
PrazSam
  • 1,166
  • 2
  • 12
  • 20

1 Answers1

1

You need to modify script conditional basis.

Pramod
  • 96
  • 7