It looks like your request as entered incorrectly with the FROM clause ... it looks like the aliases are sloppy
from room_price a, room_price,a1 room_price,room_price a2
and should be
from room_price a, room_price a1, room_price a2
This MAY give the query a false alias / extra table giving some kind of Cartesian product that causes it to hang.
--- ok in the FROM clause ...
In addition, and just a thought ... Since the "Room" seems to be an internal column of the auto-increment identifier, it will never be duplicated, for example, number 100 in hotel A and number 100 in hotel B. Your request to do <> in the room, so that you never compare across all three tables ...
Why not make a1 and a2 join only the room MORE than the "room". Otherwise, you will retest the same conditions again and again. From your example data, just at Hotel A, you have the IDs of rooms 1, 2, and 3. Thus, you compare
a a1 a2 1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1
It would only help to compare where "a1" is always greater than "a" and "a2" is always greater than "a1", thereby doing tests
a a1 a2 1 2 3
will give the same results as everything else, and thus inflate your result to one record in this case ... but then, as you can compare with the location of only two types of rooms "hotel B". You will never get an answer, as your qualifications for rooms
a <> a1 AND a <> a2 AND a1 <> a2
You might want to try to reduce only one independent union for a1, a2 and keep the comparison with only two, for example
select a1.hotel, a1.price + a2.price from room_price a1, room_price a2 where a1.hotel = a2.hotel and a2.room > a1.room For hotel "A", you would thus have final result comparisons of a1 a2 1 2 1 3 2 3 and for hotel "B" a1 a2 4 5