Example Return a substring of a string before a specified number of delimiter occurs: SELECT SUBSTRING_INDEX("www.w3schools.com", ".", 2); Try it Yourself » ❮ Previous ❮ MySQL Functions Next ❯ Track your progress - it's free! Log in Sign Up ...
Browser Support substring()is an ECMAScript1 (JavaScript 1997) feature. It is supported in all browsers: ChromeEdgeFirefoxSafariOperaIE YesYesYesYesYesYes ❮PreviousJavaScript StringReferenceNext❯ Track your progress - it's free! Log inSign Up...
Works in:From MySQL 4.0 More Examples Example Extract a substring from the text in a column (start at position 2, extract 5 characters): SELECTSUBSTRING(CustomerName,2,5)ASExtractString FROMCustomers; Try it Yourself » Example Extract a substring from a string (start from the end, at pos...
Extract 3 characters from a string, starting in position 1: SELECTSUBSTRING('SQL Tutorial',1,3)ASExtractString; Try it Yourself » Definition and Usage The SUBSTRING() function extracts some characters from a string. Syntax SUBSTRING(string,start,length) ...