user_account_history 表里有一个  call_start_time 字段, 类型是: datetime我想查询2008年10月10日的通话记录,执行下列语句:
select callee_number,call_start_time,call_time,count_time,call_paid where to_day(call_start_time,'YYYYMMDD')='20081010';之后报错:
#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 'where to_day(call_start_time,'YYYYMMDD')='20081010'' at line 1 哪位朋友知道请告诉小弟一声,谢谢了.

解决方案 »

  1.   

    select callee_number,call_start_time,call_time,count_time,call_paid where 
    DATE_FORMAT(call_start_time,'%Y%m%d')='20081010';
      

  2.   

    谢谢wwwwa的回复,执行后还是报错.如下:#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 'where DATE_FORMAT(call_start_time,'%Y%m%d')='20081010'' at line 1 
      

  3.   

    to_days函数不是这么用的。汗!
      

  4.   

    select callee_number,call_start_time,call_time,count_time,call_paid 
    FROM TT where DATE_FORMAT(call_start_time,'%Y%m%d')='20081010';呵呵,表名没有?
      

  5.   

    没有说明从哪个表中查询
    少了 from 表名
      

  6.   

    select callee_number,call_start_time,call_time,count_time,call_paid from user_account_history  where to_day(call_start_time,'YYYYMMDD')='20081010';
      

  7.   

    谢谢 yueliangdao0608 和 WWWWA 的回复.请问我想把上面的那条语句执行后拷贝到一个 .xls 文档保存起来,应该如何执行?在不登陆到mysql>的提示符下,就在系统的提示符下,我想用一条语句来执行,谢谢.
      

  8.   

    谢谢 gjrzh 的回复.我如果想在系统中执行,是这么写吗?谢谢.
    /usr/bin/mysql -u用户名 -d数据库名 "select callee_number,call_start_time,call_time,count_time,call_paid 
    FROM TT where DATE_FORMAT(call_start_time,'%Y%m%d')='20081010'"
      

  9.   


    http://blog.chinaunix.net/u/29134/showart_1120575.html
      

  10.   

    mysql> select version();
    +---------------------+
    | version()           |
    +---------------------+
    | 4.1.18-standard-log |
    +---------------------+
    1 row in set (0.01 sec)[root@antong2 ~]# /usr/bin/mysql -u root -d bolas -c "create table temp as  SELECT callee_number, call_start_time, call_time, count_time, call_paid FROM user_accounting_history WHERE DATE_FORMAT( call_start_time, '%Y%m%d' ) = current_date-1"
    /usr/bin/mysql: unknown option '-d'请问 -d 数据库 -c 执行语句 的参数是否有错?