• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

LIKE with % along with =

How can I use a LIKE statement along with an equal sign.  In other words, the query below finds similar URLs in my links index, but it does not find exact matches.  Something like WHERE blah blah LIKE OR = blah blah.  Seems logical, doesn't work that way.

SELECT *
FROM dbo.NWL_LINKS
WHERE (SUBSTRING(LEFT(URL, CHARINDEX('//', URL) + 1) + LEFT(SUBSTRING(URL + '/', CHARINDEX('//', URL + '/') + 2, 255), CHARINDEX('/',                         SUBSTRING(URL + '/', CHARINDEX('//', URL + '/') + 2, 255)) - 1), CHARINDEX('/', URL) + 2, 255)                         LIKE SUBSTRING(LEFT('12345', CHARINDEX('//',                         '12345') + 1)                         + LEFT(SUBSTRING('12345' + '/', CHARINDEX('//',                         '12345' + '/') + 2, 255), CHARINDEX('/',                         SUBSTRING('12345' + '/', CHARINDEX('//',                         '12345' + '/') + 2, 255)) - 1), CHARINDEX('/',                         '12345') + 2, 255)) AND (URL <> '12345')
ORDER BY LinkID, URL


Thanks,
Michael
0
movoni
Asked:
movoni
  • 3
1 Solution
 
movoniAuthor Commented:
Sorry about the messy formating.. didn't catch that before I posted.
0
 
zupi5Commented:
try WHERE blah = 'exact_value' OR blah LIKE '%value%'
0
 
movoniAuthor Commented:
Uhg... so repeat a very long blah 2x.  Ok, lemme try that.
0
 
movoniAuthor Commented:
I just repeated it.  Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now