小弟写了一个应用,用C来访问mysql时出现了问题,如下:
sprintf(buff,   "select   *   from   selectFood   where   selectFoodTime   > =   '2006-6-20   00:00:00'   \ 
&&   selectFoodTime   <=   '2009-1-01   23:59:59'   \ 
order   by   tableID   desc"); 
总是报错:Segmentation   fault 。一直找不到,不知道是什么原因。求高人指点以下啊!多谢!等待中...   

解决方案 »

  1.   

    sql 语法要求子句有一定的顺序
    select ..
      from ..
     where ..
     group by ..
    having ..
     order by ..
      

  2.   

    上面的程序有是按照sql的语法写的啊?
      

  3.   

    直接写 'and' 试试看
      

  4.   

    将buff里的东东print出来,在mysql的命令行执行一下。
      

  5.   

    sprintf是不是还有个参数的,我记得是格式参数,没有了可不可以用的?你那个sql语句看不出有什么问题。
      

  6.   

    谢谢各位!我换成and后还是有错啊!
      

  7.   

    select      tableID       from       selectFood       where       selectFoodTime  between('2006-6-20       00:00:00' , '2009-1-01       23:59:59'   )  order       by       tableID       desc;
      

  8.   

    select tableID from selectFood where
    selectFoodTime between('2006-6-20 00:00:00','2009-1-01 23:59:59')
    order by tableID desc;
    ==>
    select tableID from selectFood where
    selectFoodTime between '2006-6-20 00:00:00' and '2009-1-01 23:59:59'
    order by tableID desc;