gpt4 book ai didi

ruby-on-rails - 用洗劫做一个手术室

转载 作者:行者123 更新时间:2023-12-04 14:47:36 26 4
gpt4 key购买 nike

一个基本问题,但我在 project page 中找不到明确的内容或 wiki .我有以下代码:

field = "secre"
Position.search( {:description_cont => field, :code_cont => field}).result(:distinct => true).to_sql
=> "SELECT DISTINCT `positions`.* FROM `positions` WHERE ((`positions`.`description` LIKE '%secre%' AND `positions`.`code` LIKE 0))"

但我的查询应该是这样的:
 => "SELECT DISTINCT `positions`.* FROM `positions`  WHERE ((`positions`.`description` LIKE '%secre%' OR `positions`.`code` LIKE 0))"

任何帮助,将不胜感激。提前致谢

最佳答案

请尝试以下操作:

Position.search( {:description_or_code_cont => field}).result(:distinct => true).to_sql

关于ruby-on-rails - 用洗劫做一个手术室,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12940629/

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