gpt4 book ai didi

mysql - MYSQL 中使用 BETWEEN 的日期

转载 作者:行者123 更新时间:2023-11-29 10:07:37 25 4
gpt4 key购买 nike

我想使用两个不同的日期显示记录。我尝试使用 Between

select * from billing where select_client = '2' and order_date BETWEEN '01/06/2018' and '30/06/2018' order by id ASC 

它还返回 7 月份的记录。我尝试使用 >= 和 <=。该查询也返回相同的记录。

select * from billing where select_client = '2' and order_date >= '01/06/2018' and order_date <= '30/06/2018' order by id ASC 

请帮我只获取两个日期之间的记录。提前致谢enter image description here

最佳答案

您必须将字符串转换为日期才能进行比较:

select * from billing where select_client = '2' and STR_TO_DATE(order_date, '%d/%m/%Y') BETWEEN STR_TO_DATE('01/06/2018','%d/%m/%Y') and STR_TO_DATE('30/06/2018','%d/%m/%Y') order by id ASC 

关于mysql - MYSQL 中使用 BETWEEN 的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51588158/

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