Organizing data output with MySQL -


i have following table data:

t1 (results):    card_id     group_id    project_id    user_id 

the tables contain actual labels are:

t2 (groups):    id    project_id    label  t3 (cards):     id    project_id    label 

there multiple entries different users.

i need writing query display results in table format totals counts corresponding card/group. here's start i'm not sure i'm on right track...

select count(card_id) ctotal, count(group_id) gtotal project_id = $projid  

unless i'm mistaken, seems need group card_id , group_id given project_id , pull out count each group

select card_id, group_id, count(user_id) mytable  project_id = 001 group (card_id, group_id); 

edit:

taking account card , group tables involves joins, query fundamentally same. still grouping card , group, , constraining project id

select c.label, g.label, count(t1.user_id) mytable t1  join groups g on t1.group_id=g.id  join cards c on t1.card_is=c.id  t1.project_id = 001  group (c.card_id, g.group_id)  order (c.card_id, g.group_id); 

i don't think can table want sql. you'll have render table in code iterating on results. how depends on language/platform using.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -