假设我有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')
可以在雅典娜雅典娜中使用
谢谢
答案 0 :(得分:1)
过滤出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'))
编辑
当column1在list1中具有值时,如果column2具有 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'))