我需要完全在客户端构建一个 Twitter 模块。
我打算使用 Twitter API对于数据和YQL越过Same Origin Policy ,以及它更高的速率限制。我以前成功地使用过这种组合。
我需要做的一件事是从一组有限的用户那里获取带有主题标签的推文列表。
This gets tweets with the #stackoverflow
hash tag by users alexdickson
and lizardbill
.
我还需要获取一组不同的推文。
This gets all tweets with the #stackoverflow
hash tag.
现在,我需要显示第二个集合但不包括第一个集合的结果。这将是结果的差异,例如 PHP 的 array_diff()
.
为了完整起见,我可能还需要通过获取两个结果的交集来实现某些目的,即出现在两个结果集中的推文列表。这类似于 PHP 的 array_intersect()
.
我已经有一段时间没有使用 SQL 了,想不出如何在 YQL 中实现这一点。
最佳答案
YQL 支持子选择(子查询)。参见 Joining Tables with Sub-selects .子选择与 IN
operator 一起使用, 过滤外部选择的结果。
对于您的特定查询,还有一个 twitter.search
Community Open Data Table可用于避免构建 Twitter URL 和使用 json
表。
select *
from twitter.search
where q="#stackoverflow"
and id not in (
select id
from twitter.search
where q="#stackoverflow from:alexdickson, OR from:lizardbill"
)
关于sql - 是否有可能在 YQL 中获得两个结果集的交集或差异?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8935288/