PHP and MySQL syntax: Difference between revisions

Jump to navigation Jump to search
m
Line 42: Line 42:
=== Query by month ===
=== Query by month ===
* mysql ex: find the records in January, 2014<ref>[http://stackoverflow.com/questions/508791/mysql-query-group-by-day-month-year sql - MySQL Query GROUP BY day / month / year - Stack Overflow]</ref>
* mysql ex: find the records in January, 2014<ref>[http://stackoverflow.com/questions/508791/mysql-query-group-by-day-month-year sql - MySQL Query GROUP BY day / month / year - Stack Overflow]</ref>
** SELECT * FROM table_name WHERE YEAR(`time`) = '2014' AND MONTH(`time`) = '1'
** SELECT * FROM table_name WHERE `time` >= '2014-01-01 00:00:00' AND `time` < '2014-02-01'
** SELECT * FROM table_name WHERE `time` >= '2014-01-01 00:00:00' AND `time` < '2014-02-01'
** SELECT * FROM table_name WHERE YEAR(`time`) = '2014' AND MONTH(`time`) = '1'


=== further reading ===
=== further reading ===

Navigation menu