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

Fahmi
  • 37,315
  • 5
  • 22
  • 31
Curtis Jones
  • 39
  • 1
  • 5
  • 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.) – jarlh Nov 21 '19 at 08:27

1 Answers1

3

You can try this-

Insert INTO TEventGolfers (intGolferID, intEventID) 
    Select MAX(intGolferID),4 From TGolfers
Fahmi
  • 37,315
  • 5
  • 22
  • 31