为什么此查询无法在PHPMyAdmin

时间:2015-08-19 09:24:42

标签: php mysql phpmyadmin

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

  

#1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以获得正确的语法   靠近''在第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
);

任何帮助将不胜感激。

5 个答案:

答案 0 :(得分:1)

在行尾用逗号替换分号

 index appntmnt_table_index(brand_id, user_id);

答案 1 :(得分:1)

这样可行。

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

更新了最后三行检查它。

答案 2 :(得分:0)

你有拼写错误 - 索引行中的分号会破坏该陈述。

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

);

只需删除分号并添加逗号即可。

答案 3 :(得分:0)

index appntmnt_table_index(brand_id, user_id);声明中有分号。

改变
index appntmnt_table_index(brand_id, user_id);

index appntmnt_table_index(brand_id, user_id),

答案 4 :(得分:0)

试试这个:

'Wait for the specified number of milliseconds while processing the message pump
'This allows excel to catch up on background operations
Sub WaitFor(milliseconds As Single)

    Dim finish As Single
    Dim days As Integer

    'Timer is the number of seconds since midnight (as a single)
    finish = Timer + (milliseconds / 1000)
    'If we are near midnight (or specify a very long time!) then finish could be
    'greater than the maximum possible value of timer. Bring it down to sensible
    'levels and count the number of midnights
    While finish >= 86400
        finish = finish - 86400
        days = days + 1
    Wend

    Dim lastTime As Single
    lastTime = Timer

    'When we are on the correct day and the time is after the finish we can leave
    While days >= 0 And Timer < finish
        DoEvents
        'Timer should be always increasing except when it rolls over midnight
        'if it shrunk we've gone back in time or we're on a new day
        If Timer < lastTime Then
            days = days - 1
        End If
        lastTime = Timer
    Wend

End Sub