Does SQL allow me to copy one field of a table to be inserted into another table?
I am thinking something along the following lines:
[code]
INSERT INTO TableTwo (
field_one,
field_two,
field_three,
field_four
)
VALUES (
'value_one',
SELECT field_x FROM TableOne,
-- or --
SELECT * FROM TableOne WHERE some_field = 'something',
'value_three',
'value_four'
);
[/code]
From what I have read, INSERT SELECT places one row of one table into another.
However, i have not seen anything that covers inserting a single field in the same manner.
Many thanks in advance for your assistance.
-
Beginner: Copying one field of a table into another (3 messages)
- Posted by: leo rio
- Posted on: January 01 2003 22:01 EST
Threaded Messages (3)
- Beginner: Copying one field of a table into another by Abhijit Gaikwad on January 02 2003 06:13 EST
- Beginner: Copying one field of a table into another by Ferhat SAVCI on January 02 2003 06:44 EST
- Beginner: Copying one field of a table into another by Abhijit Gaikwad on January 03 2003 03:22 EST
-
Beginner: Copying one field of a table into another[ Go to top ]
- Posted by: Abhijit Gaikwad
- Posted on: January 02 2003 06:13 EST
- in response to leo rio
Hi leo rio ,
You can do this as long as your sub-query ,
"SELECT field_x FROM TableOne"
or
"SELECT * FROM TableOne WHERE some_field = 'something'"
Returns only 'one' ROW ( actullay 'one' VALUE).
Cheers,
@bhijit -
Beginner: Copying one field of a table into another[ Go to top ]
- Posted by: Ferhat SAVCI
- Posted on: January 02 2003 06:44 EST
- in response to leo rio
Ooops!
What's wrong with:
insert TableTwo
select 'value one',field_x,'value three','value four'
from TableOne
where some_filed = 'something'; -
Beginner: Copying one field of a table into another[ Go to top ]
- Posted by: Abhijit Gaikwad
- Posted on: January 03 2003 03:22 EST
- in response to Ferhat SAVCI
Nothing !
But question was about 'inserting a single field'.
Cheers,
@bhijit