Reputation: 13
I am in the process of creating a new table of mock user id's and looking to combine first and last names into the new column UserIDs. I am successful in using the CONCAT string to combine the values; however, I have been unsuccessful in combining that with an INSERT INTO
statement.
This is what I am attempting:
INSERT INTO person_userid
CONCAT(FirstName, LastName) as UserID
from person_UserID.
Upvotes: 0
Views: 54
Reputation: 44746
You want UPDATE
, not INSERT
:
UPDATE person_UserID SET UserID = CONCAT(FirstName, LastName)
Upvotes: 0
Reputation: 133360
If you want use an insert select you should use this way
INSERT INTO person_userid (user_id)
select CONCAT(FirstName, LastName)
from person_UserID
but if the rows already exists could be you need a simple update ..
update person_userid
set user_id = CONCAT(FirstName, LastName)
Upvotes: 1