MySQL

Using LIKE to Search Part of a String in MySQL

A short note on using MySQL LIKE for prefix, suffix, and contains searches.

June 30, 2018

Context

I needed to find users by part of a phone number and had to confirm the correct LIKE pattern.

Patterns

  • `mobile like "4558%"` finds values that start with 4558.
  • `mobile like "%4558"` finds values that end with 4558.
  • `mobile like "%4558%"` finds values that contain 4558.