Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT INTO from same table

Status
Not open for further replies.

johnaregan

Programmer
Mar 13, 2001
87
Hello
I want to insert rows selected from the same table using the INSERT INTO... SELECT... statement. The only difference is one column containing the user name, so I need to replace the user name with a new one that i specify. Can this be done without creating a temporary table?

Thanks in advance for any suggestions
John
 
Do you just want to update the username?
If so why not just use if they are all going to have the same username
UPDATE tablename SET USERNAME = 'xxx'
 
insert into tableX(columnX, columnXX)
select X, XX from TableY John Fill
1c.bmp


ivfmd@mail.md
 
What i want to do is to do the SQL equivelent of copyig a set of rows, reinserting them into the same table from which they came but changing the username to another.
the table format is something like:
Table name USERS
username col1
Bob AX
Bob BX
Bob CX

i want to be able to get this from 1 SQL statement
username col1
Bob AX
Bob BX
Bob CX
Bill AX
Bill BX
Bill CX

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top