How to insert a series of keys into another column

I just disappeared. I have a lot of relationships with three tables. Lets call them A, B, and C. C stores the primary keys of the other two tables.

Now I would like to insert all primary keys from table A and let 1 primary key from B into table C. I just don't get it. All I came up with was some stored procedure that takes the cursor through all the primary keys of A and inserts them from 1 to C. Guess there is a much easier way to do this.

Any help is appreciated!

0


a source to share


1 answer


I would say:

INSERT INTO C
SELECT A_Id, 1
FROM A

      



where 1 is the only primary key from B

.

Let's open it here for more information on the instructions INSERT

.

+1


a source







All Articles