使用select语句查询

maorui1029 2012-04-18 07:09:06
查询条件表达式要求出生日期在1990年之后
...全文
365 27 打赏 收藏 转发到动态 举报
写回复
用AI写文章
27 条回复
切换为时间正序
请发表友善的回复…
发表回复
boyqing 2012-05-08
  • 打赏
  • 举报
回复
各位楼上,请注意,在数据库中查询与日期相关时建议使用函数!!!

SELECT * FROM tb
WHERE DATEDIFF(yy,'1990-1-1',birthday)>=0

具体情况,可根据实际做出变化。
jsboy299 2012-05-08
  • 打赏
  • 举报
回复
select * from tb where birthday >='1900-01-01 00:00:00'
whj210082 2012-05-07
  • 打赏
  • 举报
回复
select * from 表名 where 出生日期 >= convert(varchar(4),出生日期,120)+'-01-01'
發糞塗牆 2012-05-06
  • 打赏
  • 举报
回复
楼主,你的问题总给我感觉就是看上去很简单,但是又不知道是不是真的那么简单的感觉。如果你存放日期的列是datatime的话,直接和1990-01-01那个数据相对比就可以啦。
bulake 2012-05-06
  • 打赏
  • 举报
回复
declare @dd datetime
set @dd= '1990-10-10'
select year(@dd)
select * from tt where year(dd)>=1990
flyfly2008 2012-04-28
  • 打赏
  • 举报
回复
select * from tb where birthday >='1900-01-01'
a394773734 2012-04-28
  • 打赏
  • 举报
回复
答案基本都大同小异。不过我觉得16的比较全面
孤独加百列 2012-04-28
  • 打赏
  • 举报
回复

select * from table where DATEPART(YEAR,生日字段) > 1989
qq517995084 2012-04-28
  • 打赏
  • 举报
回复

select * from table where 生日字段 >='1990-01-01'
xugan666 2012-04-28
  • 打赏
  • 举报
回复
select * from tb where birthday >='1990-01-01'
CHOUYUNHAT 2012-04-28
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 的回复:]
select * from TB where birthday like '1990%%'
[/Quote]

这个恐怕不行吧,2000年之后的查不出来
半度浮尘 2012-04-28
  • 打赏
  • 举报
回复
select * from TB where birthday like '1990%%'
傲雪飞狐 2012-04-28
  • 打赏
  • 举报
回复

select * from TB where Year(生日字段) > 1989
99归一 2012-04-25
  • 打赏
  • 举报
回复

select * from tb where birthday >='1990-01-01 00:00:00'
answer3zzw 2012-04-25
  • 打赏
  • 举报
回复
select * from tb where cast(substring(birthday,1,4) as int)>1990
substring(birthday,1,4)是取birthday的年,cast("" as int)是把年的类型转换成int,再和1990进行比较
houyajin 2012-04-25
  • 打赏
  • 举报
回复
各种答案都有了。
十三门徒 2012-04-24
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]
SQL code

select * from tb where year(birthday) > 1989
[/Quote]
Lyongt 2012-04-24
  • 打赏
  • 举报
回复
select * from tb where birthday >='1990-01-01 00:00:00'
以学习为目的 2012-04-24
  • 打赏
  • 举报
回复
select * from tb where birthday >='1900-01-01 00:00:00'
寂小魔 2012-04-23
  • 打赏
  • 举报
回复

select * from tb where year(birthday) > 1989
加载更多回复(4)

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧