from
...
join Event as FirstEvent
on FirstEvent.place_id = g.place_id
where
..
and FirstEvent.event_id = @first_event
select
Result.*
from
(
# все, кроме определенных
select
id_first_msg,
id_topic,
num_views,
0 as priority
from
smf_topics
where
id_topic not in (1,2,3,4)
# те, которые должны быть всегда включены
union
select
id_first_msg,
id_topic,
num_views,
1 as priority
from
smf_topics
where
id_topic in (5,6,7,8,9)
order by
priority desc,
num_views desc
limit 50
) as Result
order by
num_views desc
# все, кроме определенных
select
id_first_msg,
id_topic,
num_views,
0 as priority
from
smf_topics
where
id_topic not in (1,2,3,4)
# те, которые должны быть всегда включены
union
select
id_first_msg,
id_topic,
num_views,
1 as priority
from
smf_topics
where
id_topic in (5,6,7,8,9)
order by
priority desc,
num_views desc
limit 50