2021年4月9日星期五

Trying to separate a FULL_NAME into FIRST_NAME and LAST_NAME in Oracle SQL, but it does not show any changes on the table itself

This code is supposed to separate full name and it does. This code works fine, except for the fact that it does not add the data to the table.

SELECT FULL_NAME  SUBSTR(FULL_NAME, 1, INSTR(FULL_NAME, ' ', 1, 1)-1) as FIRST_NAME,  SUBSTR(FULL_NAME, INSTR(FULL_NAME, ' ', -1)+1) as LAST_NAME  from customers;  

This code runs similarly but again, does not populate the table.

ALTER TABLE CUSTOMERS;    SELECT      substr("A1"."FULL_NAME", 1, instr("A1"."FULL_NAME", ' ', 1, 1) - 1)                 "FIRST_NAME",      substr("A1"."FULL_NAME", instr("A1"."FULL_NAME", ' ',(- 1)) + 1)                    "LAST_NAME"  FROM      "XXXX"."CUSTOMERS" "A1";  

This is what my query result is, it shows that everything is how it should be.

This is what my table looks like but as you can see, the last two columns do not have any data.

My goal is to be able to drop the FULL_NAME column, but I need these two split first and I am not sure why it is not working. Any help is appreciated.

https://stackoverflow.com/questions/67030439/trying-to-separate-a-full-name-into-first-name-and-last-name-in-oracle-sql-but April 10, 2021 at 11:06AM

没有评论:

发表评论