sql - 试图找到喜欢和不喜欢的替代方法 (SQL)

标签 sql sql-server-2008

SELECT.....

 (v1.PCG like 'n0%'
or
v1.PCG like 'n1%'
or
v1.PCG like 'n2%'
or
v1.PCG like 'n3%'
or
v1.PCG like 'n4%'
or
v1.PCG like 'n5%'
or v1.PCG='N63Af1')

and v1.PCG not like 'N2D%'
and v1.PCG not like 'N2E%'
and v1.PCG not like 'N2C%'
and v1.PCG not like 'N2F%'
and v1.PCG not like 'N2J%'
and v1.PCG not like 'N2K%'
and v1.PCG not like 'N2U%'
and v1.PCG not like 'N2GC%'
and v1.PCG not like 'N2GD%'
and v1.PCG not like 'N2GH%'
and v1.PCG not like 'N2GJ%'
and v1.PCG not like 'N2GK%'
) as 'Value Of PN Orders',

from........

我已经完成了我的代码,但我正在尝试找到一种更有效的方法来执行此操作,我看了看但找不到其他方法...有什么建议吗?

最佳答案

Like 支持字符类 so;

where v1.PCG like 'n[12345]%'

关于sql - 试图找到喜欢和不喜欢的替代方法 (SQL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16940945/

相关文章:

sql-server - 如何找到 MS SQL Server 2008 的端口?

mysql - 这个查询看起来优化了吗?

php - 实现 Mult 的更好方法。 PHP 中 1 篇文章的类别?

sql - 将 SQL Server View 结果插入表

sql - 获取 .BAT 文件或 SQLCMD 以提示用户输入

sql-server - MSSQL 2008 - 只选择一种方式或路线

mysql - SQL - 如何在 LIKE 中使用通配符作为普通字符

sql - 如何在 Postgres 中使用带通配符的组

mysql - 修改这条SQL语句

sql - 防止 MS-SQL 表中的循环引用