gpt4 book ai didi

sql - 日期大于给定日期查询的 Rails

转载 作者:行者123 更新时间:2023-12-03 06:46:43 29 4
gpt4 key购买 nike

尝试搜索上映日期晚于今天的电影

 Movie.where('release > ?', Date.today)
ActiveRecord::StatementInvalid: Mysql::ParseError: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'release > '2011-09-25')' at line 1: SELECT `movies`.* FROM `movies` WHERE (release > '2011-09-25')

最佳答案

Rails 3+:

Movie.where('release > ?', DateTime.now)
<小时/>

Pre Rails 3

Movie.where(['release > ?', DateTime.now])

关于sql - 日期大于给定日期查询的 Rails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7549851/

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