select name, test from (
select name, test from (select name, test from post where category_id=2 limit 0,4) t2
union
select name, test from (select name, test from post where category_id=3 limit 0,5) t3
union
select name, test from (select name, test from post where category_id=1 limit 0,18) t1
) t
limit 0,18