Reputation: 521
I have two tables.
Table A:
a b
----
1 2
3 4
and a table B with only one row
c d e
------
5 6 7
I want to create a new table which looks like this:
a b c d e
----------
1 2 5 6 7
3 4 5 6 7
i.e copy the single row from B into all rows in A. Note: Using SAS proc sql.
Upvotes: 2
Views: 652
Reputation: 164184
First add 3 columns to your TableA
:
ALTER TABLE TableA ADD c INTEGER;
ALTER TABLE TableA ADD d INTEGER;
ALTER TABLE TableA ADD e INTEGER;
Then update TableA
with the values from TableB
:
UPDATE a
SET a.c = b.c, a.d = b.d, a.e = b.e
FROM TableA a CROSS JOIN TableB b;
See the demo.
Results:
| a | b | c | d | e |
| --- | --- | --- | --- | --- |
| 1 | 2 | 5 | 6 | 7 |
| 3 | 4 | 5 | 6 | 7 |
Upvotes: 4
Reputation: 11
INSERT IGNORE INTO Table A select * from Table B; so basically I am merging the two table, considering that the table DDL is the same.
Upvotes: 0