Skip to content

Instantly share code, notes, and snippets.

@mrowles
Created December 9, 2015 23:58
Show Gist options
  • Save mrowles/ed00cd982fe3cbb9bc26 to your computer and use it in GitHub Desktop.
Save mrowles/ed00cd982fe3cbb9bc26 to your computer and use it in GitHub Desktop.
Get longest first word in column
SELECT SUBSTRING_INDEX( `field_name` , ' ', 1 ) AS `field_name_first_word`
FROM `table_name`
ORDER BY LENGTH(`field_name_first_word`) desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment