In some cases, pattern matches are equivalent to substring comparisons. : SUBSTRING « String « SQL / MySQL






In some cases, pattern matches are equivalent to substring comparisons.

      

Pattern match                      Substring comparison
str LIKE 'abc%'                    LEFT(str,3) = 'abc'
str LIKE '%abc'                    RIGHT(str,3) = 'abc'

   
    
    
    
    
    
  








Related examples in the same category

1.SUBSTRING(, )
2.SUBSTRING(, , )
3.Sorting by Variable-Length Substrings
4.Create Initial name with substr function
5.SUBSTRING( ) function takes a string and a starting position, returning everything to the right of the positio
6.Substrings can be used to perform comparisons.
7.Sort using combinations of substrings
8.Get 3-letter substrings from the dept column
9.Get the numeric middle part by beginning with the ID, then stripping off the rightmost suffix