MySQL function to separate out first and last name from a column of full names

I wrote a pretty nice MySQL function to separate out first and last names if you just have a column of full names. Figured I'd share:

SELECT SUBSTRING_INDEX( customer_name, ' ', 1 ) AS FirstName, if( SUBSTRING_INDEX( customer_name, ' ', -1 ) LIKE "%jr%", SUBSTRING_INDEX( customer_name, ' ', -2 ) , if( SUBSTRING_INDEX( trim( customer_name ) , ' ', -1 ) = SUBSTRING_INDEX( trim( customer_name ) , ' ', 1 ) , '', SUBSTRING_INDEX( trim( customer_name ) , ' ', -1 ) ) ) AS LastName
FROM `customer`