Using SQL, how do I update rows, using their own values?

I have the following table which I'll call 'example'

id name       last_name
01 Adam       Adams
02 Bill       Billo
03 Cathy      McCathyson

I need to modify the table and end up with the following:

id name
01 Adam Adams
02 Bill Billo
03 Cathy McCathyson

For a single row, I know how to write this query:

UPDATE example SET name = 
   (SELECT name FROM example WHERE id = 01)+" "
   +(SELECT last_name FROM example WHERE id = 01)
WHERE id = 01;

How do I modify this query such that it updates each row with that row's values, as in the example?

EDIT: I've updated my example since it confused the issue.

Answers


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 * from example
  2  /

        ID NAME                    LAST_NAME
---------- -----------------------------------------
         1 Adam Adams              Adams
         2 Bill Billo              Billo
         3 Cathy McCathyson        McCathyson

Need Your Help

How To Turn JS Objects To HTML And Style With CSS

javascript html css json css-selectors

I'm learning JSON (or JS Objects) and I'm trying to figure out how to bring said objects into HTML and style them using CSS.

How to combine two variable in ascx file

c# javascript html asp.net

I want to use javascript to open a window when people click on the name.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.