SQL SELECT WHERE 字符串以列结尾 [英] SQL SELECT WHERE string ends with Column
本文介绍了SQL SELECT WHERE 字符串以列结尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 SQL Server 2012 中有这个表:
I have this table in SQL Server 2012:
Id INT
DomainName NVARCHAR(150)
并且该表具有这些 DomainName 值
And the table have these DomainName values
- google.com
- microsoft.com
- othersite.com
还有这个值:
mail.othersite.com
并且我需要选择字符串以列值结尾的行,对于这个值,我需要获取第 3 行 othersite.com
and I need to select the rows where the string ends with the column value, for this value I need to get the row no.3 othersite.com
是这样的:
DomainName Like '%value'
但反过来...
'value' Like %DomainName
推荐答案
您可以使用这样的查询:
You can use such query:
SELECT * FROM TABLE1
WHERE 'value' LIKE '%' + DomainName
这篇关于SQL SELECT WHERE 字符串以列结尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文