如何在 SQL Select 语句中检查 List 中的特定字符串?

How to check a specific string in List on a SQL Select statement?

我想知道是否可以在 select 语句中添加类似下面代码的条件,如果可以,我应该怎么做?

看起来像这些的代码

SELECT first_name ,last_name FROM persons_table [condition: WHERE last_name is on exclusiveList]

应该是

SELECT first_name ,last_name FROM persons_table 
WHERE last_name in ('name1','name2',,,,'nameN')
SELECT first_name ,last_name FROM persons_table 
WHERE last_name in (select name from table2)

SELECT first_name ,last_name FROM persons_table 
WHERE Exists(select top 1 name from table2 where table2.columnname=persons_table.last_name)
SELECT * FROM TABLE_NAME WHERE REGEXP_LIKE(COLUMN_NAME,'REGEXP');

如果您的 exclusiveList 在另一个 table 上,您可以这样做:

SELECT first_name ,last_name FROM persons_table 
WHERE last_name in (select lastName from exclusiveListTable)

甚至更好:使用 join 作为过滤器:

select * from  -- or select A.* from
(SELECT first_name ,last_name FROM persons_table) A
inner join
(select lastName from exclusiveListTable ) B
on A.last_name = B.lastName