mysql table structure with multiple variables

前端 未结 2 1302
无人共我
无人共我 2021-01-25 14:59

I am writing a script which will counts the number of ticket as per as different conditions and store the count in a summary table. I am unable to understand how to structure my

相关标签:
2条回答
  • 2021-01-25 15:26

    Wrong approach. Do not splay an array across columns. Instead have rows for the data. This lets you trivially "add" another month.

    For displaying, well that is an application problem, no a MySQL problem. Sure, you can write specialized queries to "pivot" the data from rows to columns, but it is messy.

    0 讨论(0)
  • 2021-01-25 15:30

    Have columns Date Service Count.

    Like so.

    Date            Service      Count
    16 May 2016     Service1     35
    

    Then when you go to display them in the report pivot them as you want. Probably better to make date an INT and either an auto number PK or composite PK of Date and Service.

    0 讨论(0)
提交回复
热议问题