我的问题是如何从这个具有特定值888的'id'的数组中提取特定对象?
[{ "token" => "1212",
"category" => "A",
"name" => "page 2",
"id" => "888"
},
{ "token" => "3434",
"category" => "B",
"name" => "page 1",
"id" => "999",
}]
我尝试过find_by,where和其他许多东西。
答案 0 :(得分:4)
您可以尝试使用"选择"在阵列上:
SELECT COUNT(1) from (
SELECT COUNT(sa.facility_hmis) AS deployed FROM facility_service_area sa GROUP BY sa.facility_hmis
)
这将返回一个包含符合条件的所有数组元素的数组。