Reputation: 1001
I've been fighting to get the SQL right on this insert statement.. here's what I'm trying to do:
I have new empty table that has a 1-to-1 relationship with another table. Since all the other columns have default values I only want to insert the primary key column as new rows from the old table. Table names are dealer
and dealer_nav
and the fields are id
and dealer_id
respectively.
Thanks!
Upvotes: 2
Views: 3142
Reputation: 37382
INSERT INTO dealer_nav(dealer_id) SELECT id FROM dealer
(or vice versa, I'm not sure which of 2 tables is new and which is old)
Upvotes: 5