Sayuj3
Sayuj3

Reputation: 307

why is this query not working in PHPMyAdmin

I have a query, it doesn't work in PHPMyAdmin, shows some Syntax Error:

#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
);

Any help would be appreciated.

Upvotes: 0

Views: 658

Answers (4)

syed suleman
syed suleman

Reputation: 542

This will work.

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
);

updated last three lines check it.

Upvotes: 1

Aman Kaur
Aman Kaur

Reputation: 321

replace semicolon with comma at the end of the line

 index appntmnt_table_index(brand_id, user_id);

Upvotes: 1

Hassaan
Hassaan

Reputation: 7662

There semicolon in the index appntmnt_table_index(brand_id, user_id); statement.

Change from

index appntmnt_table_index(brand_id, user_id);

To

index appntmnt_table_index(brand_id, user_id),

Upvotes: 0

SWiggels
SWiggels

Reputation: 2296

You have typo - the semicolon in the index line breaks the statement.

index appntmnt_table_index(brand_id, user_id);

so this part is invalid:

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

);

Just remove the semicolon and add a comma.

Upvotes: 0

Related Questions