目录
1.选择表中的若干列
select Sname,2021-Sage
from Student;
//目标列表达式还可以用字符串,函数
用当前年月减去年龄就得到出生年
select Sname,'Year of Birth',2021-Sage,LOWER(Sdept)
from Student;
LOWER(Sdept)表示吧Sdept列的输出数据改为小写
可以用UPPER(Sdept)改为大写
‘Year of Birth’表示输出一列Year of Birth,列名为’Year of Birth’
也可以把这里改为 ‘Year of Birth’ BIRTH 这样列名就是 BIRTH
2. 选择表中的若干元组
2.1消除取值重复的行
select Sno
from SC;
select distinct Sno//去重
from SC;
查询了SC表的全部Sno
2.2比较大小
select Sname
from Student
where Sdept='CS';