0

I've added the column DVDAtTime and I'm and trying to insert values using a subquery. Seems rather straight forward but I keep getting an error that I can't insert null into (I believe) an unrelated field in the table. Ultimately, DVDAtTime should be the number shown in MembershipType

My code is as follows:

Insert Into Membership(DVDAtTime)
Select LEFT(MembershipType,1)
FROM Membership

enter image description here

1
  • 1
    INSERT creates new rows. Because you specify only one column, those new rows have NULL for all the other columns. UPDATE, however, amends the contents of existing rows. Commented Jul 3, 2021 at 21:44

1 Answer 1

2

I suspect you want to update each existing row, not insert new rows:

update membership
    set DVDAtTime = left(MembershipType, 1)
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.