hmnc Posted August 22, 2006 Report Share Posted August 22, 2006 sveiki! vienvārdsakot ir viena tabula ar rakstiem un tur kolonna ar kategorijām. teiksim ir 5 kategorijas. jautājums sekojošs - vai var ar vienu(!) queriju izvilkt ārā visu piecu kategoriju pēdējos 10 rakstus? cik es te padomāju - man nesanāca :) db: mysql (ir gan 5.1, bet ja querijs būs specifisks tieši >5.x tad vajadzētu pateikt :) ) Paldies! Link to comment Share on other sites More sharing options...
Delfins Posted August 22, 2006 Report Share Posted August 22, 2006 (edited) select * from tabula where id IN (select id from tabula order by datums DESC, laiks DESC group by id, kategorija limit 5) PS: vajadzētu strādāt... Edited August 22, 2006 by Delfins Link to comment Share on other sites More sharing options...
hmnc Posted August 22, 2006 Author Report Share Posted August 22, 2006 a man iekš 5.1 bļauj, ka versija nesuportē LIMIT iekš subkvērijiem. bļin.. izstrādes db 3.23 :D par to laikam vispār var aizmirst, bet baigi vpadlu likt 5.1... varianti? Link to comment Share on other sites More sharing options...
Delfins Posted August 22, 2006 Report Share Posted August 22, 2006 sql1 = selects ids sql2 = select * from tabula where id IN (implode(...)) Link to comment Share on other sites More sharing options...
Recommended Posts