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

how to filter out any combination of two lists in SQL?

假设我有 list1 (1,2,3,4,5,6,7,8,9) 和 list2 ('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'))
select * from table1
except
select * from table1
where column1 in (1,2,3,4,5,6,7,8,9) and column2 in ('a','b','c','d')

在 amazon athena 中可以使用

谢谢

filter out the rows where column1 equals any values in list1 and column2 equals any values in 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'))


编辑

When column1 has a value in list1, filter out this row if column2 has a value in list2


这意味着:

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