Jump to content
php.lv forumi

Recommended Posts

Posted

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ā.

Posted (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 by codez
Posted

Ī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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...