If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > SQL Query Help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-22-04, 16:10
Crayon69 Crayon69 is offline
Registered User
 
Join Date: Mar 2004
Posts: 2
SQL Query Help

hi,

how would i select something from one table and put it into another, ie select name from details table and insert it into friends table? can it be done in one statement, i'm lost?!!

thanks alot
Reply With Quote
  #2 (permalink)  
Old 03-22-04, 16:19
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
A lot depends on how you define "one statement", but you can certainly use:
Code:
INSERT INTO friends (name) SELECT DISTINCT name FROM details
to take one copy of each name from the details table and place them into the friends table.

It is your call as to whether that is one compound statement, or two atomic statements. From an execution standpoint, they are a single statment executed by the SQL engine. From a syntax standpoint, they are two separate statements that are executed as one.

-PatP
Reply With Quote
  #3 (permalink)  
Old 03-22-04, 16:28
Crayon69 Crayon69 is offline
Registered User
 
Join Date: Mar 2004
Posts: 2
well i dont mind one or two statements either way as long as it works
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On