您的 SQL 语法错误,要在 'join-date DATE,credit DOUBLE(15,0) zerofill,PRIMARY KEY(id) )' 附近使用正确的语法

You have an error in your SQL syntax on for the right syntax to use near 'join-date DATE,credit DOUBLE(15,0) zerofill,PRIMARY KEY(id) )' at line

create table clients_info (
  id MEDIUMINT NOT NULL AUTO_INCREMENT,
  name CHAR(30) NOT NULL,
  join-date DATE,
  credit DOUBLE(15,0) zerofill,
  PRIMARY KEY(id)
);

You have an error in your SQL syntax on for the right syntax to use near 'join-date DATE,credit DOUBLE(15,0) zerofill,PRIMARY KEY(id) )' at line

正如@GordonLinoff 所说,默认情况下不允许在列名中使用连字符 (-)(在 identifiers 中)。不过,如果将标识符括在反引号中,则可以使用它,如:

create table clients_info (
  id MEDIUMINT NOT NULL AUTO_INCREMENT,
  name CHAR(30) NOT NULL,
  `join-date` DATE,
  credit DOUBLE(15,0) zerofill,
  PRIMARY KEY(id)
);

或者更好,使用下划线 (_) 来避免在任何地方使用反引号,如:

create table clients_info (
  id MEDIUMINT NOT NULL AUTO_INCREMENT,
  name CHAR(30) NOT NULL,
  join_date DATE,
  credit DOUBLE(15,0) zerofill,
  PRIMARY KEY(id)
);

个人更喜欢后者