为什么此查询在 PHPMyAdmin 中不起作用

why is this query not working in PHPMyAdmin

我有一个查询,它在 PHPMyAdmin 中不起作用,显示一些语法错误:

#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 12

create table appntmnt(
 appointment_id bigint unsigned not null primary key auto_increment,
 user_id bigint unsigned not null,
 br_id bigint unsigned,
 brandname text,
 brname text,
 strt_time bigint unsigned,
 end_time bigint unsigned, 
 is_cancelled boolean,
 is_confirmed boolean,
 app_ser text,
 index appntmnt_table_index(brand_id, user_id);
 foreign key foreign_key1(user_id) references user(user_id) on delete cascade,
 foreign key foreign_key2(branch_id) references branch(branch_id) on delete cascade
);

如有任何帮助,我们将不胜感激。

您有错字 - 索引行中的分号打断了语句。

index appntmnt_table_index(brand_id, user_id);

所以这部分是无效的:

foreign key foreign_key1(user_id) references user(user_id) on delete cascade,
foreign key foreign_key2(branch_id) references branch(branch_id) on delete cascade

);

只需删除分号并添加一个逗号。

index appntmnt_table_index(brand_id, user_id);语句中有分号。

变化自

index appntmnt_table_index(brand_id, user_id);

index appntmnt_table_index(brand_id, user_id),

将行尾的分号替换为逗号

 index appntmnt_table_index(brand_id, user_id);

这会起作用。

create table appntmnt(
 appointment_id bigint unsigned not null primary key auto_increment,
 user_id bigint unsigned not null,
 br_id bigint unsigned,
 brandname text,
 brname text,
 strt_time bigint unsigned,
 end_time bigint unsigned, 
 is_cancelled boolean,
 is_confirmed boolean,
 app_ser text,
 index appntmnt_table_index(br_id, user_id),
 foreign key foreign_key1(user_id) references user(user_id) on delete cascade,
 foreign key foreign_key2(br_id) references branch(branch_id) on delete cascade
);

更新了最后三行检查一下。