We may occasionally need to search within a string for a certain text. Multiple built-in functions provided by MySQL made the task simple.
To extract a substring from a string, use the MID, SUBSTR, and SUBSTRING functions (starting at any position). All three of these functions perform similarly and give the same result.
Examples:
SELECT MID(“Big Data and SQL”, 5, 4) AS ExtractString;
SELECT SUBSTR(“Big Data and SQL”, 5, 4) AS ExtractString;
SELECT SUBSTRING(“Big Data and SQL”, 5, 4) AS ExtractString;
Since we specified the start location and length of the string to be extracted from that place, all of the aforementioned returns “Data” as the outcome.