• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • 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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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