2

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!

2
  • the other values can be blank.. defaults are already set in the structure of the table.. all other fields n the new table are boolean with FALSE (0) as default Commented Dec 2, 2010 at 15:57
  • what have you tried, what exactly is the problem and what error-message are you facing? you're describing what you wan't to do (thanks for that, most peaople miss that part), but we don't know whats the problem with it... Commented Dec 2, 2010 at 15:59

1 Answer 1

5

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.