我想知道是否可以在select语句中添加类似下面代码的条件,如果是,我应该怎么做?
代码看起来像这些
SELECT first_name,last_name FROM persons_table [condition:WHERE last_name在exclusiveList上]
答案 0 :(得分:3)
如果您的exclusiveList在另一个表上,您可以这样做:
String
甚至更好:使用join作为过滤器:
SELECT first_name ,last_name FROM persons_table
WHERE last_name in (select lastName from exclusiveListTable)
答案 1 :(得分:0)
应该是
SELECT first_name ,last_name FROM persons_table
WHERE last_name in ('name1','name2',,,,'nameN')
答案 2 :(得分:0)
SELECT first_name ,last_name FROM persons_table
WHERE last_name in (select name from table2)
OR
SELECT first_name ,last_name FROM persons_table
WHERE Exists(select top 1 name from table2 where table2.columnname=persons_table.last_name)
答案 3 :(得分:-1)
SELECT * FROM TABLE_NAME WHERE REGEXP_LIKE(COLUMN_NAME,'REGEXP');