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 哪位朋友知道请告诉小弟一声,谢谢了.
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 哪位朋友知道请告诉小弟一声,谢谢了.
DATE_FORMAT(call_start_time,'%Y%m%d')='20081010';
FROM TT where DATE_FORMAT(call_start_time,'%Y%m%d')='20081010';呵呵,表名没有?
少了 from 表名
/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'"
http://blog.chinaunix.net/u/29134/showart_1120575.html
+---------------------+
| 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 执行语句 的参数是否有错?