SQL SELECT WHERE string ends with Column

流过昼夜 提交于 2020-12-04 15:33:02

问题


I have this table in SQL Server 2012:

Id INT 
DomainName NVARCHAR(150)

And the table have these DomainName values

  1. google.com
  2. microsoft.com
  3. othersite.com

And this value:

mail.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

It's something like this:

DomainName Like '%value' 

but in reverse ...

'value' Like %DomainName

回答1:


You can use such query:

SELECT * FROM TABLE1
WHERE 'value' LIKE '%' + DomainName


来源:https://stackoverflow.com/questions/25413692/sql-select-where-string-ends-with-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!