获取语​​法错误

时间:2015-12-03 15:48:19

标签: php mysql

这里,我在mysql中导入数据,但是语法错误。

  

您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册,以获得正确的语法,以便在IGNORE 1 LINES'附近使用。在第1行

我的代码:

$result = mysql_query("LOAD DATA INFILE 'D:\orderitems-100081669.txt' INTO TABLE tbl_order_details IGNORE 1 LINES FIELDS TERMINATED BY '\t' ENCLOSED BY '\"' LINES TERMINATED BY '\n' (@col1,@col3,@col4,@col7,@col8) set orderdet_id=@col1,orderdet_productid=@col3,orderdet_iscase=@col4,orderdet_qty=@col7,  orderdet_price_sold=@col8;")or die ('Error: '.mysql_error ());

1 个答案:

答案 0 :(得分:2)

您已将LOAD DATA INFILE 'D:\orderitems-100081669.txt' INTO TABLE tbl_order_details FIELDS TERMINATED BY '\t' ENCLOSED BY '\"' LINES TERMINATED BY '\n' IGNORE 1 LINES (@col1,@col3,@col4,@col7,@col8) SET orderdet_id=@col1,orderdet_productid=@col3,orderdet_iscase=@col4,orderdet_qty=@col7, orderdet_price_sold=@col8; 放在错误的位置。

请参阅documentation

尝试

public static int invalidlines = 0;
public static int validlines = 0;
public static int stats1 = 0;
private static Scanner input;
public static ArrayList<String> validList = new ArrayList<String>();
public static ArrayList<Integer> stats = new ArrayList<Integer>(); {
    if (stats.isEmpty());
    display("n/a");
}
static int sum(ArrayList<Integer> stats)
{
    int value = 0;
    for(int i : stats)
    {
        value += i;
    }
    return value;
}