0

I typed the following code And I don't know what's wrong with my code.

CREATE TABLE SlotGame
(
  gID CHAR(12),
  jackpot DECIMAL(10,2) NOT NULL,
  sID CHAR(5) NOT NULL,
  PRIMARY KEY(gID),
  FOREIGN KEY(gID) REFERENCES Game(gID),
  FOREIGN KEY(sID) REFERENCES Slot(sID),
);

The following is shown to me:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 9

Hope someone can tell me what's wrong. Thanks a lot.

2
  • Please note that actually the tables 'Game' and 'Slot' have already created by me.
    – dannail
    Oct 27, 2011 at 1:53
  • Is line 9 the ); line? If so, then what's wrong with line 8?
    – S.Lott
    Oct 27, 2011 at 1:54

1 Answer 1

6

You just need to remove the last comma:

CREATE TABLE SlotGame
(
  gID CHAR(12),
  jackpot DECIMAL(10,2) NOT NULL,
  sID CHAR(5) NOT NULL,
  PRIMARY KEY(gID),
  FOREIGN KEY(gID) REFERENCES Game(gID),
  FOREIGN KEY(sID) REFERENCES Slot(sID) <-- comma removed
);

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.