Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何过滤SQL中两个列表的任意组合?_Sql_Amazon Athena - Fatal编程技术网

如何过滤SQL中两个列表的任意组合?

如何过滤SQL中两个列表的任意组合?,sql,amazon-athena,Sql,Amazon Athena,假设我有列表1(1,2,3,4,5,6,7,8,9)和列表2('a','b','c','d')) 如何筛选出column1同时等于list1中的任何值和column2同时等于list2中的任何值的行 比如: select * from table1 where (column1 not in (1,2,3,4,5,6,7,8,9) and column2 not in ('a','b','c','d')) or (column1 in (1,2,3,4,5,6,7,8,9) and column

假设我有列表1(1,2,3,4,5,6,7,8,9)和列表2('a','b','c','d')) 如何筛选出column1同时等于list1中的任何值和column2同时等于list2中的任何值的行

比如:

select * from table1
where (column1 not in (1,2,3,4,5,6,7,8,9) and column2 not in ('a','b','c','d'))
or (column1 in (1,2,3,4,5,6,7,8,9) and column2 not in ('a','b','c','d'))
or (column1 not in (1,2,3,4,5,6,7,8,9) and column2 in ('a','b','c','d'))
这在亚马逊雅典娜行得通

谢谢

筛选出column1等于list1和list1中任何值的行 第2列等于列表2中的任何值


这意味着:

select * from table1
where (column1 not in (1,2,3,4,5,6,7,8,9) and column2 not in ('a','b','c','d'))
select * from table1
where (column1 not in (1,2,3,4,5,6,7,8,9) or column2 not in ('a','b','c','d'))

编辑

当column1在list1中有值时,如果column2有值,则过滤掉此行 列表2中的值


这意味着:

select * from table1
where (column1 not in (1,2,3,4,5,6,7,8,9) and column2 not in ('a','b','c','d'))
select * from table1
where (column1 not in (1,2,3,4,5,6,7,8,9) or column2 not in ('a','b','c','d'))

您的第二个查询将使用
而不是
——尽管它也会删除重复项。