gpt4 book ai didi

php - 使用 Mysql 查找即将到来的生日

转载 作者:行者123 更新时间:2023-11-28 23:42:17 25 4
gpt4 key购买 nike

我想在 MYSQL 中选择下一个即将到来的生日。我的日期存储为:02/19/1981 而不是在日期字段中。我认为它必须按日和月而不是年排序,但我不知道如何排序。

我该怎么做?这是到目前为止的查询:

$sql = "SELECT * FROM wp_postmeta WHERE meta_key='_web_date' ORDER BY ....";

最佳答案

如果您可以将日期列更改为键入 date .

否则试试这个:

SELECT month(str_to_date(birthdayColumn, "%m/%d/%Y")) as month, day(str_to_date(birthdayColumn, "%m/%d/%Y")) as day FROM yourTable order by month, day;

结果:

+-------+------+| month | day  |+-------+------+|     1 |   12 ||     2 |   19 ||     9 |   10 ||    12 |   15 |+-------+------+

关于php - 使用 Mysql 查找即将到来的生日,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34167191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com