Jump to content

Grouping into weeks


karimali831

Recommended Posts

Hi,

 

I have a basic group league setup for 16 signups, 8 registers in group A and other 8 in group B and use two unions in my query to generate all combinations (all vs. all) which means it will always be 16 / 2 (A and B) * 7 weeks = 56 matches.  (28 matches for group A and 28 for group B) each competitor will have 7 matches each and I am trying to split these matches in separate tables and just haven't got a clue to how or where to start?

 

There should be 7 tables showing 4 matches each per group.

 

Query:-

                   safe_query("INSERT INTO ".PREFIX."cup_matches ($type, $type_opp, matchno, clan1, clan2, comment, 1on1) 
                   (SELECT a.$type,
                          a.$type_opp,
                          a.matchno,
                          a.clan1,
                          b.clan2 AS 'versus',
                          a.comment,
                          a.1on1
                   FROM ".PREFIX."cup_matches a
                        JOIN ws_bi2_cup_matches b ON a.$type = b.$type AND b.$type = '$let_alpha' 
                                                           AND b.matchno = '$ID' 
                                                           AND a.clan2 != b.clan2				
                                                           AND b.type = 'gs'
                   WHERE a.matchno = '$ID'
                     AND a.type = 'gs')
                   UNION
                   (SELECT a.$type,
                          a.$type_opp,
                          a.matchno,
                          a.clan1,
                          b.clan1 AS 'versus',
                          a.comment,
                          a.1on1
                   FROM ".PREFIX."cup_matches a
                        JOIN ws_bi2_cup_matches b ON a.$type = b.$type AND b.$type = '$let_alpha' 
                                                           AND b.matchno = '$ID' 
                                                           AND a.clan1 < b.clan1 
                                                           AND b.type = 'gs'
                   WHERE a.matchno = '$ID'
                     AND a.type = 'gs')		     
                   UNION
                   (SELECT a.$type,
                          a.$type_opp,
                          a.matchno,
                          a.clan2,
                          b.clan2 AS 'versus',
                          a.comment,
                          a.1on1
                   FROM ".PREFIX."cup_matches a
                        JOIN ws_bi2_cup_matches b ON a.$type = b.$type AND b.$type = '$let_alpha' 
                                                           AND b.matchno = '$ID' 
                                                           AND a.clan2 < b.clan2 
                                                           AND b.type = 'gs'
                   WHERE a.matchno = '$ID'
                     AND a.type = 'gs')	   
                   ORDER BY clan1 DESC, versus");

 

Table:

http://s13.postimage.org/48mcpf1dx/solved.png

solved.png

 

Anyone understand what I am trying to do?

 

Thanks for any help.

Link to comment
Share on other sites

Your question is a bit hard to make out, at least for me.  So you are basically creating a script that generates team match-ups in a league,  one team vs another team.  That part makes sense.  The next is a tad unclear.  How are you wanting to split the information?  one table for each competitor showing all of their matches?

 

Perhaps a little more insight into how you want the final tables organized would be helpful in finding an answer :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.