select hotelkod hotel_kod,name_hu AS hotelnev,telepkod,case when hotelkod in (select l.hotelkod from fix_right_links as l where (start<=now() and end is NULL) or (start is NULL and end>=now()) or (start<=now() and end>=now()) or (start is NULL and end is NULL)) then 1 else 0 end as fix from hotel where publikus=1 order by fix desc,original desc,rand() limit 18