My 'name' column has names stored like this
Lastname Firstname Middlename
I want to display it like this in my query:
Firstname Middlename Lastname
- Not all records have a middle name, so they may be 1 or 2 spaces in the column
I have tried this :
SELECT CONCAT ( SUBSTRING_INDEX(`name`, ' ', 1) , ' ' , SUBSTRING_INDEX(`name`, ' ', -1) ) AS nicename`
But this only gives the last name. The "-1" part is not working...
Thanks for all help.