File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Duplicate values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Duplicate values " Watch "Duplicate values " New topic

Duplicate values

Sharadha Sankar

Joined: Feb 15, 2006
Posts: 20
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

Thanks<br />Sharadha
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1082

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(').


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
I agree. Here's the link:
subject: Duplicate values
It's not a secret anymore!