gpt4 book ai didi

mysql - mysql查询时如何获取时间?

转载 作者:行者123 更新时间:2023-11-29 16:06:08 25 4
gpt4 key购买 nike

如何用正确的 SQL 查询编写此 Rails 查询?

time = (Time.now - 1.days).beginning_of_day
Assignment.where("created_at >= :time OR updated_at >= :time", time: time).pluck(:assignable_id).uniq

你能帮我在 SQL 查询中转换它吗?

select distinct assignable_id from assignments where created_at >= getDate() && updated_at >= getDate();

我需要有关如何在查询时获取日期的帮助?

最佳答案

您可以使用 CURDATE() 使用 MySQL 获取日期。

您的查询将如下所示:

select distinct assignable_id from assignments where created_at >= CURDATE() AND updated_at >= CURDATE();

关于mysql - mysql查询时如何获取时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55721936/

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