Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
232 views
in Technique[技术] by (71.8m points)

sql server - SQL SELECT WHERE string ends with Column

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
question from:https://stackoverflow.com/questions/25413692/sql-select-where-string-ends-with-column

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use such query:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...