
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How MySQL SUBSTRING_INDEX() function returns the substring if we provide the negative value of the argument ‘count’?
MySQL SUBSTRING_INDEX() function can accept the negative value of argument ‘count’ and in this case, it returns the substring from the right of the final delimiter.
Example
mysql> Select SUBSTRING_INDEX('www.google.com','.',-2); +------------------------------------------+ | SUBSTRING_INDEX('www.google.com','.',-2) | +------------------------------------------+ | google.com | +------------------------------------------+ 1 row in set (0.00 sec) mysql> Select SUBSTRING_INDEX('www.google.com','.',-1); +------------------------------------------+ | SUBSTRING_INDEX('www.google.com','.',-1) | +------------------------------------------+ | com | +------------------------------------------+ 1 row in set (0.00 sec)
- Related Articles
- What MySQL returns if we provide value larger than 255 as argument to MySQL CHAR() function?
- What MySQL ELT() function returns if we the index number, provided as an argument, is less than 1?
- What MySQL returns if the argument of QUOTE() function is NULL?
- What MySQL returns if we use UNIX_TIMESTAMP() function with no argument?
- What MySQL EXPORT_SET() function returns if any of the argument is NULL?
- What MySQL returns if the first argument of INTERVAL() function is NULL?
- What MySQL returns if I provide a non-hexadecimal number as an argument to UNHEX() function?
- What happens if we provide NULL as an argument to MySQL CHAR() function?
- What MySQL ELT() function returns if the index number, provided as an argument, is higher than the number of strings?
- How can we extract a substring from the value of a column in MySQL table?
- How can we replace all the occurrences of a substring with another substring within a string in MySQL?
- Get the index of last substring in a given string in MySQL?
- What MySQL returns if the list of strings, provided as argument in FIELD() function, are NULL?
- What MySQL returns if we use NULL, as both the arguments, as one of the argument and as a separator, in CONCAT_WS() function?
- What MySQL ASCII() function returns if I will provide NULL to it?

Advertisements