Ruby on Rails的ActiveRecord如何与ID数组实现长尾词连接查询?
- 内容介绍
- 文章标签
- 相关推荐
本文共计161个文字,预计阅读时间需要1分钟。
以下是对伪原创内容的
plaintext以下命令在拉取具有特定功能的所有样式时非常有用:使用Style.joins(:style_features).where('style_features.feature_id=?', 1)。这可以实现类似的功能,但针对一系列功能吗?例如:使用Style.joins(:style_features).where(...)。
以下命令在拉出具有特定功能的所有样式时非常有用:Style.joins(:style_features).where('style_features.feature_id= ?', 1)
有可能做同样的事情,但对于一系列功能?如:
Style.joins(:style_features).where('style_features.feature_id= ?', [1, 2, 3]) 你可以简单地做:
Style.joins(:style_features).where(style_features: { feature_id: [1, 2, 3] })
此查询将让Rails根据您定义的DataBase Adapter处理SQL查询.
本文共计161个文字,预计阅读时间需要1分钟。
以下是对伪原创内容的
plaintext以下命令在拉取具有特定功能的所有样式时非常有用:使用Style.joins(:style_features).where('style_features.feature_id=?', 1)。这可以实现类似的功能,但针对一系列功能吗?例如:使用Style.joins(:style_features).where(...)。
以下命令在拉出具有特定功能的所有样式时非常有用:Style.joins(:style_features).where('style_features.feature_id= ?', 1)
有可能做同样的事情,但对于一系列功能?如:
Style.joins(:style_features).where('style_features.feature_id= ?', [1, 2, 3]) 你可以简单地做:
Style.joins(:style_features).where(style_features: { feature_id: [1, 2, 3] })
此查询将让Rails根据您定义的DataBase Adapter处理SQL查询.

