如何在 sql server 2005 中使用具有多个值的类似条件? [英] How to use like condition with multiple values in sql server 2005?

查看:23
本文介绍了如何在 sql server 2005 中使用具有多个值的类似条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要根据 nvarchar(1000) 列中的某些文本匹配来过滤掉记录.表有超过 40 万条记录并且还在不断增长.现在,我使用 Like 条件:-

I need to filter out records based on some text matching in nvarchar(1000) column. Table has more than 400 thousands records and growing. For now, I am using Like condition:-

SELECT 
    *
FROM
    table_01
WHERE
    Text like '%A1%'
    OR Text like '%B1%'
    OR Text like '%C1%'
    OR Text like '%D1%'

有什么首选的解决方法吗?

Is there any preferred work around?

推荐答案

SELECT 
    *
FROM
    table_01
WHERE
    Text like '%[A-Z]1%'

这将检查文本是否包含 A1, B1, C1, D1, ...

This will check if the texts contains A1, B1, C1, D1, ...

参考在 SQL Server 中使用 Like Condition

Reference to using the Like Condition in SQL Server

这篇关于如何在 sql server 2005 中使用具有多个值的类似条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆