Foxtable(狐表)用户栏目专家坐堂 → [求助] 这条SQL查询怎么写?


  共有21751人关注过本帖树形打印复制链接

主题:[求助] 这条SQL查询怎么写?

帅哥哟,离线,有人找我吗?
yuanbin
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子: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。


 回到顶部