Collections:
SUBSTRING_INDEX() - Substring in Delimited String
How to extract a substring from a delimited string using the SUBSTRING_INDEX() functions?
✍: FYIcenter.com
SUBSTRING_INDEX(str, delim, N) is a MySQL built-in function that
returns a substring from a string ending before the Nth delimiter.
For example:
SET @str = 'dba.FYIcenter.com'; SELECT SUBSTRING_INDEX(@str, '.', -2); -- +--------------------------------+ -- | SUBSTRING_INDEX(@str, '.', -2) | -- +--------------------------------+ -- | FYIcenter.com | -- +--------------------------------+
Reference information of the SUBSTRING_INDEX() function:
SUBSTRING_INDEX(str, delim, N): substr Returns the substring from string str before N occurrences of the delimiter delim. If N is positive, everything to the left of the final delimiter (counting from the left) is returned. If N is negative, everything to the right of the final delimiter (counting from the right) is returned. Arguments, return value and availability: str: Required. The string that will be extracted from. delim: Required. The delimiter used in the string. N: Required. The number of times to search for the delimiter. substr: Return value. The substring extracted. Available since MySQL 4.0.
⇒ TO_BASE64() - Base64 Encoding
⇐ SUBSTRING() - Substring at Given Position
2023-11-13, 1214🔥, 0💬
Popular Posts:
How to put statements into a statement block in SQL Server Transact-SQL? You can put statements into...
Where to find answers to frequently asked questions on Downloading and Installing SQL Server 2005 Ex...
How To Use SQL*Plus Built-in Timers in Oracle? If you don't have a stopwatch/timer and want to measu...
Where to find SQL Server Transact-SQL language references? You can find SQL Server Transact-SQL lang...
How To Connect the Oracle Server as SYSDBA in Oracle? This is Step 4. The best way to connect to the...