Mysql query help needed
- by Me-and-Coding
Hi,
i have two tables category and hotels where category.id should be equal to hotels.catid. Now how do i select 3 rows from each different category from the hotels table.
I have this query:
select h.* from hotels h inner join category c on h.catid = c.id
order by h.catid, h.hid
this selects all records, but i want to select three rows per different category so in all it should return 9 rows with 3 rows for each category.
If this can not be done in mysql, you could also suggest php code please.
Thanks