select substring(custmer_name, 1, instr(custmer_name, ' ')) as first_name from sales.customers;
This solution gave me the answer, but it doesn't work for the last name
Using SUBSTRING_INDEX()Requires 3 parameters:
You can find more instructions here Article
Inquire
SELECT SUBSTRING_INDEX(customer_name,' ', 1) as first_name, SUBSTRING_INDEX(customer_name,' ', -1) as last_name FROM customer;
Please test it: I use the locate function to define the location of " ".
SELECT LEFT(customer_name, LOCATE(' ',customer_name)-1) as first_name, RIGHT(customer_name, LENGTH(customer_name)-LOCATE(' ',customer_name)) as last_name FROM customer;
Result set:
Using SUBSTRING_INDEX()Requires 3 parameters:
You can find more instructions here Article
Inquire
Please test it: I use the locate function to define the location of " ".
Result set: