gpt4 book ai didi

ruby - 这个怎么写比较好? Ruby Sequel 链接或

转载 作者:数据小太阳 更新时间:2023-10-29 06:48:25 24 4
gpt4 key购买 nike

在 SQL 中它应该是这样的:

SELECT * FROM `categories_description_old` WHERE ((`categories_description` = '') OR (`categories_name` = '') OR (`categories_heading_title` = ''))

我的(丑陋的)解决方案:

conditions = [:categories_name, :categories_heading_title, :categories_description]
b = table_categories_description_old.filter(conditions.pop => "")
conditions.each do |m|
b = b.or(m => "")
end

是否有更好的解决方案来链接 or 条件?

最佳答案

 DB[:categories_description_old].
filter({:categories_description=>'',
:categories_name=>'',
:categories_heading_title=>''}.sql_or)

关于ruby - 这个怎么写比较好? Ruby Sequel 链接或,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4185883/

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