SQL寻找以'〜0000'结尾的零件号

问题描述 投票:1回答:1

我正在尝试查找以〜0000结尾的记录,例如ABC〜0000但我尝试的所有方法似乎均不起作用。一些例子:

    and left (mfr_part_number, 4) = 'ABC~'  -- finds nothing
    and left (mfr_part_number, 3) = 'ABC'   -- finds stuff
    AND RIGHT(MFR_PART_NUMBER, 4) = '0000'  -- finds nothing
    AND RIGHT(MFR_PART_NUMBER, 5) = '~0000' -- finds nothing
    and DbFunctions.Like(MFR_PART_NUMBER,'%0000') -- suggested elsewhere, but not recognized in MSSMS.

我正在使用:

    SQL Server Management Studio                    15.0.18206.0
    Microsoft Analysis Services Client Tools        15.0.1567.0
    Microsoft Data Access Components (MDAC)         10.0.18362.1
    Microsoft MSXML                                 3.0 6.0 
    Microsoft .NET Framework                        4.0.30319.42000
    Operating System                                10.0.18363

谢谢!

sql search wildcard tilde
1个回答
0
投票

您是否在WHERE子句中使用所有这些AND语句?如果是这样,那么如果没有符合所有条件的数据,则将不会返回任何内容。

尝试

SELECT column1, column2...
FROM yourdb
WHERE MFR_PART_NUMBER LIKE '%0000'
© www.soinside.com 2019 - 2024. All rights reserved.