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

Inserting into Table A based on a value in Table B, How?

Status
Not open for further replies.
Sep 30, 2003
1
US
I need to insert rows into Table A based on a value in Table B. I als need a column in Table B to populate one of the values during the insertions. I've tried joining and subqueries but can't seem to get it to work.

Is this type of insert possible and if so, what is the syntax?

Thanks in advance.
 
Hi

Try this..

INSERT authors (firstName, lastName)
SELECT newAuthors (firstName, lastName)
^-- this is all ONE command.


The column sequence in the two tables MUST match if you wish to use the "*" char in the SELECT part of the command, and use only the table name in the INSERT part of the command.





-=-=-=-=-=-=-=-=-
For ease of reading, any posted CODE should be wrapped by [ignore][COLOR]
and
Code:
[/ignore] tags.

Ex:
Code:
SELECT 1 from sysobjects

 
Dear Friend:
Can you give some realistic table and field names to know what to do.
usually it is too easy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top