Code: Select all
Table: pre_room
room_id
name
table: pre_allocation
allocation_id
room_id
date
allocationCode: Select all
select r.room_id, count(allocation_id) as total from pre_room r, pre_allocation a where r.room_id = a.room_id and ('2006-09-15' <= a.date and adddate('2006-09-15', interval 2 day) >= a.date) and a.allocation > 5 group by r.room_idIs there any way I can add something so that rooms where total is less than 2 are NOT returned? I can't put the count, or it's alias (total) into the where clause without MySQL complaining.