#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 'alter table totalinfo add result1 varchar(50) not null after SelfId' at line 1sql语句
alter table totalinfo add result1 varchar(50) not null after SelfId之前看到网上添加字段用的以下方法
alter table totalinfo add result3 varchar(50)  not null after `SelfId` 这个是可以执行的很是奇怪,后面的``是可以省略的呀。为什么会出现上述报错呢?

解决方案 »

  1.   

    mysql 什么版本,在5.5下没有问题
      

  2.   

    5.6也是没问题的你是否是在这句sql前面还有执行的语句?
      

  3.   

    5.5.2版本的mysql 
      

  4.   

    我在php执行的代码如图,绿色注释掉的都是可以执行的。只是到了插入字段时候就开始报错了。把echo印出来的sql语句,在管理器中操作,竟然不能执行了。
      

  5.   

    MYSQL应该不支持 after 
      

  6.   

     真的么?怪不得使用phpmyadmin有时候这个命令可以执行,有时候就开始包上面的错误。
    请问ACMAIN_CHM,我在php中该如何实现,增加一个新的字段到表格,并且这个字段在特定的字段之前。这样就不用循环插入某列之后了。
      

  7.   

    看了网上的学习手册,是可以使用after和first 语句的。看来应该是phpadmin或者php有问题了?真是个难题,就卡到这一步了,做不好后面web引用的grid插件顺序完全乱了。
      

  8.   

    mysql 5.1没问题
      

  9.   

    alter table totalinfo add `result1` varchar(50) not null after `SelfId`
    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 'alter table totalinfo add `result1` varchar(50) not null after `SelfId`' at line 1
    又重新修改了,以下是php代码。上面的是报错信息。 
    语法上感觉是没有错误的呀,纠结死了。mysql5.5.20 php 5.3.1 难道是版本问题?php语言使用的utf8,表格设置为utf*-genernal-ci编码,字段中有Time记录导入记录的时间。
    $test = "alter table totalinfo add `".$add_af."` varchar(50) not null after `".$be_title."`";
    echo $test."</br>";
    $query0 = mysql_query($test);//echo $be_title;
    echo mysql_error();
      

  10.   

    mysql5.5 是支持after的,但不支持first,执行出错需要看SelfId字段存不存在