Compare only day and month with date field in mysql

前端 未结 4 452
慢半拍i
慢半拍i 2020-11-30 07:16

How to compare only day and month with date field in mysql? For example, I\'ve a date in one table: 2014-07-10

Similarly, another date 2000-07-10<

4条回答
  •  难免孤独
    2020-11-30 07:45

    Use MONTH and DAY functions:

    Try this:

    SELECT *
    FROM tableA a 
    WHERE a.id = 1 AND MONTH(a.field) = MONTH('2000-07-10') AND 
          DAY(a.field) = DAY('2000-07-10') 
    

提交回复
热议问题