Sorgu ile yapılabilecek bir işlemi php ile yapmamak gerekir.

SELECT DISTINCT harfadi FROM XXX ORDER BY harfadi, RANDOM() LIMIT 4
dener misiniz?