I need to make a query that gets fields that corresponds that month for each month of each year
something like this:
field 1 field 2
count_of_fields_that_corresponds_this_month, same_fields_but_with_value_true
--------------------------------------------|--------------------------------
january |
--------------------------------------------|-------------------------------
february |
--------------------------------------------|--------------------------------
march |
--------------------------------------------|--------------------------------
april |
--------------------------------------------|--------------------------------
etc... |
in this example i have 2 fields that i need to fill in the table, but in reality i have many more, but i don’t know how to get that fields for each month in one query, i have tried to make the same thing but with many queries, and i think its a bad practice, so can you advice me how to do this? or what functions i need to use in mysql?
i want to take field1, field2, field3, etc…. for each month, and if is possible also for each year, thank you very much.
$this->db->query("SELECT count(*) AS count FROM `simple` WHERE `ochistka` = 'somevalue' AND MONTH(`date`) = 01");
$this->db->query("SELECT count(*) AS count FROM `simple` WHERE `ochistka` = 'somevalue' AND MONTH(`date`) = 01 AND `prime4anie` = 'somevalue'");
so in this queries i am getting that fields, but only for one month, how can i improve it and make them query for each month in one shot(query)?
put your own field and table names