gpt4 book ai didi

php - Mysql cli 和 phpmyadmin - 给出不同的结果

转载 作者:行者123 更新时间:2023-11-29 19:15:59 25 4
gpt4 key购买 nike

我有以下查询:

SELECT `report_table_cottage_rented`.`cottage_id`     AS 
report_table_cottage_rented___SP___cottage_id,
`report_table_cottage_rented`.`cottage_name` AS
report_table_cottage_rented___SP___cottage_name,
`report_table_cottage_rented`.`end_time` AS
report_table_cottage_rented___SP___end_time,
`report_table_cottage_rented`.`rented_days` AS
report_table_cottage_rented___SP___rented_days,
`report_table_cottage_rented`.`rented_weekend` AS
report_table_cottage_rented___SP___rented_weekend,
`report_table_cottage_rented`.`rented_weeks` AS
report_table_cottage_rented___SP___rented_weeks,
`report_table_cottage_rented`.`start_time` AS
report_table_cottage_rented___SP___start_time
FROM `report_table_cottage_rented`
WHERE 1 && ( `report_table_cottage_rented`.`start_time` BETWEEN
'2016-01-01' AND '2016-12-31 23:59:59' )

对我来说这似乎很好。

通过 mysql cli 运行时,上面的查询给出了不同的结果(只有 2 个结果 - 错误),而通过 phpmyadmin 则给出了不同的结果(5410 个结果 - 正确)。

当查询通过 php 内置函数 mysql_query() 运行时,我得到相同的错误答案。

我不知道出了什么问题。

最佳答案

您的 Between 必须是: BETWEEN '2016-01-01 00:00:00' AND '2016-12-31 23:59:59' 。否则 mysql 将使用实际的时间戳,这会随着时间的推移产生不同的结果。

顺便说一句:不要使用已弃用的 mysql_* API。使用mysqli_*PDO

关于php - Mysql cli 和 phpmyadmin - 给出不同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42713794/

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