Created
June 6, 2012 18:25
-
-
Save javierguerrero/2883732 to your computer and use it in GitHub Desktop.
SQL Exact Match
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @Tab TABLE( | |
[id] int, | |
[test] varchar(100)) | |
INSERT INTO @Tab | |
VALUES (1, 'This is a test searching for like.') | |
INSERT INTO @Tab | |
VALUES (2, 'This is a test for alike messages.') | |
INSERT INTO @Tab | |
VALUES (3, 'It is likely the effort will fail.') | |
INSERT INTO @Tab | |
VALUES (4, 'I like rainy days.') | |
INSERT INTO @Tab | |
VALUES (5, 'like') | |
INSERT INTO @Tab | |
VALUES (6, 'I like') | |
INSERT INTO @Tab | |
VALUES (7, 'like hi.') | |
SELECT * | |
FROM @Tab | |
WHERE | |
test LIKE '%[^a-z]like[^a-z]%' OR | |
test LIKE 'like[^a-z]%' OR | |
test LIKE '%[^a-z]like' OR | |
test = 'like' | |
/* | |
The [^a-z] says that the characters before and | |
after must not be letters a-z. I hope this solves it for you! | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment