?
Solved

sql insert question

Posted on 2001-06-08
8
Medium Priority
?
206 Views
Last Modified: 2010-04-06
I need to insert some table (padronf) with all it's records and fields into another table (padron) which has the same records (I mean the same names) plus one which is autonumber. So to be short, I need the SQL statement to insert all the records in padronf into padron and generate the correct autonumbers for IdAfi.
I know this is done with the INSERT keyword but don't know the correct sintax.

So, do you know how to do this? I suppose you do, so please help me.

thanks.
0
Comment
Question by:pin_plunder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 8

Expert Comment

by:Cesario
ID: 6168426
Hi,


try this statments ;-)

MERGE SELECT * FROM padron
  WITH SELECT * FROM padronf

Regrads

Cesario
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6168539
Insert into padron (FieldList_AutoincField_Excluded) Select (FieldList_AutoincField_Excluded) from padronf
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6168557
sorry, should be

Insert into padron (FieldList_AutoincField_Excluded) Select FieldList_AutoincField_Excluded from padronf

;-)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:pin_plunder
ID: 6171095
Cesario: I get the error 'Invalid use of the given token: MERGE'.

kretch..: there are 20 fields, I won't write all there names twice. And, I must say I tried to do so, but not  autonumber is 'created'.

thanks.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6171265
>but not  autonumber is 'created'.

is this number for the autonumberfield not provided by your databasesystem?
what databasesystem do you use?
0
 

Author Comment

by:pin_plunder
ID: 6171775
sorry, just corrected that. However, my question now is the following: is there any way to avoid duplicate records. Supose I run the sql command with the insert statement. Now I do this again. So, those records will be twice in padron.db.

can I avoid this?

thanks.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6172885
well

insert into padron select * from padronf where autonumberfield not in (select autonumberfield from padron)
0
 
LVL 2

Accepted Solution

by:
Felixin earned 150 total points
ID: 6248966
Did you try

Insert into padron (FieldList_AutoincField_Excluded) Select DISTINCT FieldList_AutoincField_Excluded from padronf

?

Felixin

Pimientos del Padron : unos pican y otros no
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month10 days, 22 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question