我将所有用户的生日都存储为 UNIX 时间戳,并且我想每天向当天生日的用户发送电子邮件.
I have all users' birthdays stored as a UNIXtimestamp and am wanting to send out e-mails each day to users that have a birthday that day.
我需要进行一个 MySQL 查询,以获取包含今天日期的生日的所有行.
I need to make a MySQL query that will get all of the rows that contain a birthday on today's date.
这看起来应该相当简单,但也许我只是把它复杂化了.
It seems like this should be fairly simple, but maybe I am just overcomplicating it.
这应该有效:
SELECT *
FROM USERS
WHERE
DATE_FORMAT(FROM_UNIXTIME(birthDate),'%m-%d') = DATE_FORMAT(NOW(),'%m-%d')
这篇关于使用 MySQL 判断今天是否是用户的生日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!