Koenman Koenman - 1 year ago 89
SQL Question

Mysql only WHERE LIKE on month

let's say i have this query:

SELECT COUNT(datum) FROM unique_ip WHERE (datum>='2016-02-01' AND datum<='2016-02-29')

I want to do a WHERE LIKE so only the month has to be specific like 01, 02 etc. So my query is only looking for this: ____-02-__ . How can i use WHERE LIKE in this case?

This is my Database scheme:


  • datum - DATE - NOT NULL (datum means date)

  • Telling - INT - NOT NULL DEFAULT = 1 (Telling meaning counting)

i'd be glad to supply you with more information if needed.

Answer Source

You can use the MONTH() function or something like SELECT COUNT(datum) FROM unique_ip WHERE datum LIKE '%-02-%';.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download