我想构建一个概念上的查询:
SELECT INTERSECT(["12","34"],(SELECT custom_id FROM USER))
理想情况下,第一个系列是即时制作的。否则可以临时收藏?这个系列的限制是什么;它可能包含数千个元素吗?
答案 0 :(得分:2)
我创建了一个数据库来测试你的案例,有不同的方法可以继续。 结构:
在您的示例中,手动传递参数并将其与查询结果进行比较,您可以尝试:
select intersect($a.left, $b.right)
let $a = (select [12, 34] as left),
$b = (select custom_id as right from User)
否则您只能使用查询来获得结果
select intersect($a.left, $b.right)
let $a = (select custom_id as left from User where custom_id = 12 or custom_id = 34),
$b = (select other_id as right from otherClass)
或第三种方法是动态构建两个列表
select intersect($a.left, $b.right)
let $a = (select [12, 34] as left),
$b = (select [1, 5, 9, 12, 28, 34, 45] as right)
答案 1 :(得分:0)
执行
select $a
let $a = (select [12, 34] as mylist)
返回
[{"mylist":[12,34]}]
执行
select $a.mylist
let $a = (select [12, 34] as mylist)
返回
[[12,34]]
执行
select $a.mylist[0]
let $a = (select [12, 34] as mylist)
返回
[12,34]
执行
select intersect($a.left[0], $b.right[0])
let $a = (select [12, 34] as left),
$b = (select [1, 5, 9, 12, 28, 34, 45] as right)
返回
[34, 12]
因此从上一个答案开始,后缀[0]是获取$ a正确引用的关键。需要list()函数将结果集的行合并到一个列表/数组中。
解决方案是:
select intersect($a.left[0], $b.right[0])
let $a = (select [12, 34] as left),
$b = (select list(custom_id) as right from User)