WHERE (SELECT count( * ) FROM gebote WHERE user_id =1 AND high_bid =1 GROUP BY category, user_id ) <3 Limit 1 Order by Rand()