0

This is the code I have and I am not sure why it doesnt work

Insert INTO TEventGolfers (intGolferID, intEventID) Values((Select MAX(intGolferID) From TGolfers),4) 

I want to insert 4 as the EventID and the max golfer id from the table TGolfers as the foreign key golfer id in the EventGolfers Table

1
  • What's expected to happen if someone later today inserts into TGolfers an even higher intGolferID value? (Your data in TEventGolfers will be out of date.) Commented Nov 21, 2019 at 8:27

1 Answer 1

3

You can try this-

Insert INTO TEventGolfers (intGolferID, intEventID) Select MAX(intGolferID),4 From TGolfers 
Sign up to request clarification or add additional context in comments.

4 Comments

The syntax used in OP should work as-is.
@SalmanA, yup, I know but this answer seems neater to me that OP's:)
More neat is not an answer!
@SalmanA, Okk, I'll keep it in my mind

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.