首页 > 数据库技术 > 详细

数据库——查询数据库如何在出生年月日中取年份

时间:2016-01-16 01:29:05      阅读:567      评论:0      收藏:0      [点我收藏+]

Year(生日),得到年
Month(生日),得到月
Day(生日),得到日
前提是这个生日是一个日期型字段。

 

查询和学号为108的同学同年出生的所有学生的Sno、Sname和Sbirthday列。

select Sno,Sname,Sbirthday from Student where Sbirthday=(select Sbirthday from Student where Sno=‘108‘) #年月日全部匹配

select Sno,Sname,Sbirthday from Student where Year(Sbirthday)=(select Year(Sbirthday) from Student where Sno=‘108‘) #只匹配年

数据库——查询数据库如何在出生年月日中取年份

原文:http://www.cnblogs.com/Chenshuai7/p/5134742.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!