使用列别名
1.中文列别名代替英文列别名
select id as 编号,name as 姓名 from tb_PersonalInfo;
2.多表查询中出现重复列名时,前面要带上表名
select tb_Student.id as 学生编号,tb_PersonalInfo.id as 员工编号 from tb_Student,tb_PersonalInfo,where tb_Student.id=tb_PersonalInfo.id
3.查询结果中添加新列
select name,math,englist,chinese,(math+english+chinese) as sumScore from tb_Score;
4.统计结果中添加列
select name,sum(math) as 数学总成绩,sum(english) as 英语总成绩,sum(chinese) as 语文总成绩 from tb_Student Group by name;
在列中计入计算
1.使用字符函数Left、Right、Mid
select name from tb_Student where right(1,枫) like "枫"//查询后一个字为枫的同学,可能是陈枫、罗枫等等
2.使用数字函数(ABS、Len等)
select name from tb_Student where Len(name)>3//查询名字长度大于3
3.使用日期时间函数
select ProductName from tb_Products where year(2010);//查询2010销售的商品
4.使用取出空格函数
select name from tb_Student were trim(name) like trim(txtName.text)//去除空格