anonīms Posted August 19, 2010 Report Share Posted August 19, 2010 INSERT INTO `ligas_komandas` (`id`, `ligas_id`, `lietotajs`, `komanda`, `konference`, `divizija`, `font`, `STREAK_WON`, `STREAK_LOST`, `F1_punkti`, `F1_komanda`) VALUES (83, 4, 1, 1, '', '', '', 0, 0, 0, 5), (84, 4, 37, 1, '', '', '', 0, 0, 0, 0); SELECT t1.*, t2.nosaukums AS komanda FROM ".PREFIX."ligas_komandas AS t1, ".PREFIX."F1_komandas AS t2 WHERE t1.ligas_id = '".$league['id']."' AND t1.komanda = t2.id ORDER BY t1.F1_komanda DESC Ideja ir tāda, ka katrā komandā ir pa 2 braucējiem un viņu F1_komanda tiek saskaitīta kopā jau selektā un beigās noorderota. Pašlaik kods strādā tā, ka tiek izvadīta komanda 2x. Varbūt var kkā izmantot DISNTICT? Mēģinaju pirms t1.* un t2.komanda, bet nekā. Quote Link to comment Share on other sites More sharing options...
Леший Posted August 20, 2010 Report Share Posted August 20, 2010 JOIN Quote Link to comment Share on other sites More sharing options...
codez Posted August 20, 2010 Report Share Posted August 20, 2010 (edited) SELECT *,GROUP_CONCAT(lietotajs),GROUP_CONCAT(F1_punkti),sum(F1_punkti) FROM komandas WHERE ligas_id=1 GROUP BY F1_komanda ORDER BY F1_komanda DESC Edited August 20, 2010 by codez Quote Link to comment Share on other sites More sharing options...
anonīms Posted August 20, 2010 Author Report Share Posted August 20, 2010 Īsti nez vai codez variants gāja pareizi, vai es pats lažu nolaidu, bet nu vismaz vajadzēja man to GROUP_CONTACT. Apčekoju un izveidoju kaut ko šādu SELECT *, ".PREFIX."F1_komandas.nosaukums AS komandas_nos, GROUP_CONCAT(F1_komanda),sum(F1_komanda) AS kom_pti FROM ".PREFIX."ligas_komandas JOIN ".PREFIX."F1_komandas ON ".PREFIX."F1_komandas.id = ".PREFIX."ligas_komandas.komanda WHERE ligas_id = '".$league['id']."' GROUP BY komanda ORDER BY kom_pti DESC Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.