mysql CONVERT

空清城 发布于 2014/02/21 15:19
阅读 789
收藏 0

@杨延庆 你好,想跟你请教个问题:

SQL 语句如下

SELECT count(*) as cjcount,rq from (SELECT rq,IP from (SELECT cast(CONVERT(varchar, VISITTIME, 23) as datetime) as rq,IP FROM YY_VISITINFO_201402 where 1=1 and cast(CONVERT(varchar, VISITTIME, 23) as datetime)>='2014-2-1' and cast(CONVERT(varchar, VISITTIME, 23) as datetime)<='2014-2-21') a group by rq,IP) b group by rq order by rq

提示

[Err] 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 'varchar, VISITTIME, 23)
as datetime) as rq,IP FROM YY_VISITINFO_201402 where 1' at line 1

 我怀疑是是convert 函数的问题.查了很多资料没有得到正确的答案..

能帮我看看不?


 

 

加载中
0
杨延庆
杨延庆

你varchar没有给长度吧?

select * from Meeting where convert(varchar(10),PublishTime,121))=@PublishTime

数据库内的信息转换为yyyy-mm-dd格式的10位字符,只要与参数相同即可返回查询结果.而convert中的121是指将datetime类型转换为char类型时获得包括世纪位数的4位年份


空清城
空清城
恩 谢了 ..
返回顶部
顶部