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


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') #只匹配年


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM