• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Duplicate values

 
Sharadha Sankar
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

This is my scenario, lets assume I have the following place table
ID Name address state country.
1 X XYZ ny us
2 A ABC nj us

Now I have to create new IDs 3, 4,5 which has the same values of ID =1.
So I figured I have to select all the value of ID =1 (Select * from place where ID = 1);

and then do a insert.

My question is how do I do the insert?.

Please help

Thanks in advance
Sharadha
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sharadha Sankar:

My question is how do I do the insert?.




You have already crossed half way

insert into place (ID ,Name ,address ,state ,country)
(Select 3, Name, address, state, country from place where ID = 1)


If your Id is a char field then dont forget to add single quotes(').

Shailesh
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic