is_lunar Whether the lunar calendar (0=solar calendar, 1=lunar calendar)
birthday birthday (date type directly saves the birthday format 1985-07-19)
How to query the record set of today’s birthday?
ps: Mysql’s date function knowledge is almost zero. I don’t know how to write it. I hope you guys can give me some advice. I’m very grateful.
This is how I write it now, it should be no problem.
$solar = 当前阳历月份和日(04-11)
$lunar = 当前农历月份和日(03-15)
select * from table where ( is_lunar = 0 and date_format(birthday, '%m-%d') = {$solar} ) or ( is_lunar = 1 and DATE_FORMAT(birthday,'%m-%d') = {$lunar})
I know a PHP class for converting lunar calendar and solar calendar. It is recommended to use PHP to convert it, and then query it after confirming a date.
SQL can probably be like this, select * from users where (is_lunar = 1 and birthday = 2017-03-15) or (is_lunar = 0 and birthday = 2017-04-11)