Introduction to String Functions
Explore how to manipulate and compare strings in MySQL using functions like LIKE and STRCMP. Learn pattern matching techniques and case sensitivity handling to improve your text-based database queries.
We'll cover the following...
MySQL provides data types with five categories of data: numeric, date and time, string, spatial, and JSON. Out of the eight distinct data types for strings, TEXT is one that we already use in our running example for representing the names of parts for car models:
As we can observe, CarPart has three columns, model, name, and built_at, of which the second represents the name of a car part using the data type TEXT. If we filter for specific car parts, e.g., 'exterior', it might feel intuitive to use the comparison operator = on the column name:
While the comparison operator = is sufficient in this case, matching strings based on criteria other than equality is not possible with this operator. Referring to other programming languages like JavaScript or Python, we know that the comparison operator = evaluates its ...