From the course: MySQL Essential Training

Unlock this course with a free trial

Join today to access over 23,700 courses taught by industry experts.

Substrings

Substrings

- [Bill] Hi, I am Bill Weinman. You may perform simple SUBSTRING operations in MySQL using the SUBSTRING function. For example, if I say SELECT SUBSTRING of this is a string, comma, six. And this will give me the string starting at the sixth position to the end of the string. And you see it says, is a string. You can also specify how many characters you want to return. Maybe I want to return only the first four characters starting six characters in. I get, is a. Or you can count from the end of the string, so I could say minus six, so give me the last six characters of the string. Oh, and it's worth noting that SUBSTR is an alias for SUBSTRING. It works exactly the same. There's also SUBSTRING INDEX which allows you to use a delimiter instead of a fixed position, you can use a delimiter as your index. And so this will get us everything from the first occurrence of a space character, so it says this. So this gives us everything up to the first occurrence of that space character. Or if…

Contents