数据库——查询数据库如何在出⽣年⽉⽇中取年份
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') #只匹配年