How to combine (stack vertically) the following 3 queries into one query , which returns 100 rows, 50 rows from category 1, 25 from category 2, 25 from category 3, all are randomly selected. I tried UNION but didn't seem to work.
select * from table where category_id = 1 order by rand() limit 50; select * from table where category_id = 2 order by rand() limit 25; select * from table where category_id = 3 order by rand() limit 25;
source share