简体   繁体   English

多个不喜欢的陈述

[英]Multiple Not Like Statements

Is there an easier(cleaner) way to accomplish the following: 是否有一种更简单(更清洁)的方法来完成以下任务:

AND Prov_Credentialing not like ('%AS%') AND Prov_Credentialing not like ('%CI%')
AND Prov_Credentialing not like ('%DI%') AND Prov_Credentialing not like ('%FQ%')
AND Prov_Credentialing not like ('%EM%') AND Prov_Credentialing not like ('%HS%')
AND Prov_Credentialing not like ('%SN%') AND Prov_Credentialing not like ('%PH%')
AND Prov_Credentialing not like ('%AN%') AND Prov_Credentialing not like ('%RQ%')

The Prov_Credentialing column could contain records that have multiple codes. Prov_Credentialing列可能包含具有多个代码的记录。 For example, a column count contain 'AS,ED'. 例如,列数包含“ AS,ED”。 Therefore, a NOT IN statement wouldn't work because I need to include any code that has the 'AS' in it. 因此,NOT IN语句将不起作用,因为我需要包含任何带有“ AS”的代码。

There are MUCH more codes that I need to exclude in the NOT LIKE statement I just listed the first 10 here. 我还需要在NOT LIKE语句中排除更多代码,在这里我只列出了前10个。

Thanks, Greg 谢谢,格雷格

Store the patterns in a separate table: 将模式存储在单独的表中:

CREATE TABLE NOT_LIKES (pattern VARCHAR(4));

INSERT INTO NOT_LIKES VALUES ('%AS%');
...

SELECT ...
WHERE  ...
AND    NOT EXISTS (SELECT * FROM NOT_LIKES WHERE Prov_Credentialing LIKE pattern)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM