Two hotels for the list

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
php idiot
Forum Newbie
Posts: 3
Joined: Mon Sep 08, 2008 8:59 am

Two hotels for the list

Post by php idiot »

There are many entries in the 'search' table
Table - 'search'
Table data - holiday details, hotel, price
In the list, I must only have two of the same hotel.
The other search criteria is that the list must be in price order.
If i do the following sql statement
select distinct hotel
from search
and then loop through the hotels and run the next sql statement
select *
from search
where hotel = (above hotelid)
limit 2
I will get 2 entries in the search table for each hotel
the problem is that the list might not be in price order
Does anybody know how to get around this?
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Two hotels for the list

Post by jaoudestudios »

Use ORDER BY price
Post Reply