I wanted to reduce the programming logic in a code that search hotels by using a single query.
Let say this is the database table. There are several contracts from a single hotel.
I wanted to get all the raws that satisfy input number of rooms for max_adults 1(capacity 1) rooms, number of rooms for rooms for max_adults 2(capacity 2) rooms and number of rooms for rooms for max_adults 3(capacity 3) rooms.
eg:
Input :The rows that satisfy all the 3 conditions with the
2 rooms of max_adults=1(capacity 1)
1 rooms of max_adults=2(capacity 2)
3 rooms of max_adults=3(capacity 3)
same hotel id
must be output.
As in here the output must contain all the raws of hotel 1 and hotel 2
Since they are two separate results, an extra column is needed to show a generated result_id (kind of serial number as in here which must has duplicates acording to this problem).
I'm thinking lots of ways to do this, but nothing works well. Will this be possible to do in a single query?