Jadi, Anda memerlukan 7 catatan acak untuk setiap jenis produk (7 * 12 catatan). Sekilas Anda hanya mencari serikat pekerja.
(SELECT * FROM products WHERE product_type_id=1 AND deleted='n' ORDER BY RAND() LIMIT 7)
UNION ALL
(SELECT * FROM products WHERE product_type_id=2 AND deleted='n' ORDER BY RAND() LIMIT 7)
UNION ALL
...
UNION ALL
(SELECT * FROM products WHERE product_type_id=12 AND deleted='n' ORDER BY RAND() LIMIT 7)
Jika Anda perlu memesan seluruh hasil maka Anda dapat menggunakan ORDER BY
klausa setelah seluruh UNION
.