數據庫——查詢數據庫如何在出生年月日中取年份


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