SUBSTR (mysql)

Date: April 26th 2016
Last updated: April 26th 2016

The substr clause lets you do things like sort a column by a subset of characters.

SUBSTR(column_name, position, length)

Useful resources

Example
Select all countries that have a population over 200,000.
Sort the output by the last 4 letters.

select distinct(name)
from my_world_table 
where population > 200000 
order by SUBSTR(name, CHAR_LENGTH(name)-3);

results matching ""

    No results matching ""