sql server - Using SQL, how do I update rows, using their own values? -
i have following table i'll call 'example'
id name last_name 01 adam adams 02 bill billo 03 cathy mccathyson
i need modify table , end following:
id name 01 adam adams 02 bill billo 03 cathy mccathyson
for single row, know how write query:
update example set name = (select name example id = 01)+" " +(select last_name example id = 01) id = 01;
how modify query such updates each row row's values, in example?
edit: i've updated example since confused issue.
update example set name = name + ' ' + last_name
id name last_name
1 adam adams 2 bill billo 3 cathy mccathyson sql> update example set name = name + ' ' + last_name 2 / 3 rows updated sql> select * example 2 / id name last_name ---------- ----------------------------------------- 1 adam adams adams 2 bill billo billo 3 cathy mccathyson mccathyson
Comments
Post a Comment