Assume this User table in PostgreSQL:
CREATE TABLE "User" (
id SERIAL PRIMARY KEY,
email text NOT NULL,
name text,
);
I want to split name into firstName and lastName and update the existing rows accordingly. I understand that I can use the following SQL to return the data as firstName and lastName:
SELECT
split_part("name", ' ', 1) AS "firstName",
split_part("name", ' ', 2) AS "lastName"
FROM "User";
I guess I now need to use UPDATE somehow in order to update the existing rows, but I'm not clear on the exact syntax.