加好友 发短信
等级:贵宾
帖子:102
积分:880
威望:0
精华:4
注册:2008/8/31 21:47:00
|
Post By:2008/11/16 11:54:00 [显示全部帖子]
在以上基础上有2种写法: 1、select a.* from (select a,b,c,cast(cast(a as char(4))+'-'+cast(b as char(2))+'-'+cast(c as char(2)) as datetime) as d from 表A) as a where d='2008-10-4'
2、select a,b,c,cast(cast(a as char(4))+'-'+cast(b as char(2))+'-'+cast(c as char(2)) as datetime) as d from 表A where cast(cast(a as char(4))+'-'+cast(b as varchar(2))+'-'+cast(c as varchar(2)) as datetime)='2008-10-4'
char 和 varchar 字符数据类型说明:固定长度用char,可变长度用varchar。
|
|