select A.ID, A.tekst, A.IDkategorije, A.datum
from tablica A
where 5 > (select count(*) from tablica B
where A.IDkategorije = B.IDkategorije and A.datum < B.datum)
and IDkategorije in (select distinct IDkategorije from tablica)
group by A.IDkategorije, A.ID order by A.IDkategorije
SELECT id,tekst,IDkategorije,datum FROM tablica GROUP BY IDkategorije ORDER BY RAND() LIMIT 5
ovo će ti vratit 5 članaka sa unique kategorijama. nego nemoj koristit "*" i ak baš ne moraš nemoj ni ORDER BY RAND() radije to php-om rješi. al ovo je fast and dirty
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum