0

I keep getting this error. What am I doing wrong? here is the code;

CREATE TABLE member(
    MEM_ID BIGINT(10) PRIMARY KEY 
);

Thanks

GMB
  • 216,147
  • 25
  • 84
  • 135

2 Answers2

0

ERROR 1064 (42000) means syntax error. So something is wrong in the definition.

  1. You could start by changing the table name to members.
  2. Then declare the PRIMARY KEY attribute later in the definition.
  3. Finally, the MEM_ID column should never be null, maybe be auto incremented, and unsigned as you'll never have negative values in it. NB: If you don't count on having billions of users, you can just use INT for this column. It will save you some space.
    CREATE TABLE members(
       MEM_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
       PRIMARY KEY(MEM_ID)
    );
0

member is a reserved word in MySQL. You need to either quote it with backticks, or better yet change the name of your table to something that is not reserved.

-- possible
CREATE TABLE `member`(MEM_ID BIGINT(10) PRIMARY KEY);

-- better
CREATE TABLE mymember(MEM_ID BIGINT(10) PRIMARY KEY);

Demo on DB Fiddle

GMB
  • 216,147
  • 25
  • 84
  • 135