cancel
Showing results for 
Search instead for 
Did you mean: 

How to circumvent the pattern limit for like

MCMartin
Participant
2,604

My problem is that I have a column with file names including paths. I want to select something from the table based on a Like 'very_long_path%'. The problem is that I receive the error "the pattern is to long"

Any advice how to get around this limitation?

Accepted Solutions (1)

Accepted Solutions (1)

Breck_Carter
Participant

LEFT ( x, 14 ) = 'very_long_path'

VolkerBarth
Contributor
0 Kudos

That answer took me some time to understand...but that seems to be due to another limit:)

Breck_Carter
Participant

...and yet ANOTHER limit (of mine) led me to misunderstand your comment: that perhaps you were saying LEFT has a limit of its own. So I went and tested with the entire text of Jabberwocky. Not an entire loss, that effort... got to read a great poem again 🙂

VolkerBarth
Contributor
0 Kudos

Guess the limit I mentioned is more besides the LEFT and RIGHT sides of my brain. Reading both SQLA and poetry may help to extend here. Sometimes it's a very_long_path to understand:)

Former Member

While Breck's solution is a good one, there are two subtleties. First, Breck's rewrite is not sargable (the rewrite can't use an index whereas the LIKE pattern can). You can adjust the rewrite to make it sargable but the rewrite is complex depending on the collation used. The other subtlety is that Breck's rewrite doesn't precisely match LIKE. LIKE is processed by comparing character-by-character; full-strings are compared with '='. This can give different semantics with some collations (see http://dcx.sybase.com/index.html#1201en/dbreference/colc.html comparison with 'Æ'='AE' vs LIKE ).

Answers (1)

Answers (1)

MCMartin
Participant

Other options are "Similar To" or "Regexp", they can use longer patterns and they will use the index