filter records per month

5

I have the following query:

$sql= mysql_query("SELECT dia, GROUP_CONCAT(hora) FROM marcacoes WHERE colaborador_id = {$colaborador_id} GROUP BY dia ");

Returns the following table:

But I want it to appear only from month 6 for example, it appears every month.

How do I display the records I have in the bank per month?

    
asked by anonymous 26.07.2016 / 19:44

1 answer

6

It is necessary to filter by the month and year, get the field containing the date apply a month() that return the month date and year() that returns the year and make the comparison with the desired value. The query should look something like this:

SELECT dia, GROUP_CONCAT(hora) FROM marcacoes
WHERE colaborador_id = {$colaborador_id} AND month(campo_data) = 6
AND year(campo_data) = 2016 GROUP BY dia
    
26.07.2016 / 19:52