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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert into a table a row from another table?

Status
Not open for further replies.

bonosa

Programmer
May 19, 2004
76
US
Is there a way to insert into one table a particular row from another table in one statement? Both tables are identical in terms of columns. Or do I have to select * from the latter and insert into values() into the first table?

Thanks,
sb
 
INSERT INTO Table1
SELECT *
FROM Table2
WHERE (Your criteria for selecting the particular row)
 
Another question. My main table has an autoincrement field. I am adding to it a line from another identically structured table. This line will probably have a number in the autoincrement field which will clash with the preexisting (unique) autoincrementing number in the main table.

How do I 'write over' the old entry which had that same number? I need that field to be autoincrementing and unique.

Thanks,
sb
 
I see--- maybe delete will do the job. Sorry for prematurely posting without thorough googling..
sb
 
That looks great. I was nervous about doing a delete on a row which might not exist,but replace seems exactly to do the job.


I just tried a delete command on a nonexistent record, and it didnt scream at me...

but I am going to replace it with replace...:)

Thanks for all the input,
sb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top