Created a table clients
using Postgres database having an order_ids
field which is an array field ( array: true
). I want to fetch only those clients whose order_ids
field contains value '220'.
Example: order_ids
contains ["12","13","220"]
. So, in where clause I want to do something like this:
Client.where("order_ids contains(?)",220)
Any idea?
Client.where("220 = ANY(order_ids)")
Rails文档中的更多用法示例
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.