小编fuz*_*uzz的帖子

使用元组数组的 SELECT 查询

我可以像这样匹配一组条件:

select ID from FOO where col1=1 and col2=2 and col3=3
Run Code Online (Sandbox Code Playgroud)

但是,如果我有一个数组,[(1,2,3), (4,5,6), (7,8,9)]在这种情况下如何获取 ID 呢?

为了澄清,我想要一种将每个元组与三列匹配的方法。如果它被打破,它将是:

select ID from FOO where col1=1 and col2=2 and col3=3

select ID from FOO where col1=4 and col2=5 and col3=6

select ID from FOO where col1=7 and col2=8 and col3=9
Run Code Online (Sandbox Code Playgroud)

如果我必须循环,就这样吧,我认为可能有一种更优雅的方法来做到这一点。

我的 sqlite 版本是 3.8.11,它随 Python 3.5.1 一起提供。

sqlite

6
推荐指数
1
解决办法
9919
查看次数

标签 统计

sqlite ×1