sql语句查询什么时候用逗号什么时候用句号

如题所述

第1个回答  2015-12-27
as用法:
是给现有的字段名另指定一个别名的意思,比如:

select username as 用户名,password as 密码 from users

补充:比如其中的一个好处是:当字段名是英文或拼音缩写时,采用汉字替代之后可以给阅读带来方便

sql中as的用法和一些经典的sql语句

1、delete table1 from (select * from table2) as t2 where table1.id=t2.id
2、truncate table table1 (不在事务日志中做记录,比delete table快,但不能激活触发器)
3、update table1 set column=column+1 where id=(select id from table2)
4、update table1 set column=column+1 from table1,table2 where table1.id=table2.id
5、select top n [Percent] * from table1 '输出百分比记录
6、select id,column1 * column2 as column from table1 '可算明白as的用法了
7、select * from table1 where column1 like 'SQL#_G_O' escape '#' '单匹配
8、select table1.id from table1 where not exists (select table2.id from table2 where table1.id=table2.id) '这个应该比not in快一些
9、select table1.id from table1,table2 where table1.id<>table2.id '看复合查询机制
10、select table1.id from table1,table2,(select id from table3) as t3 where table1.id=table2.id and table2.id=t3.id '有些类似[1]了......
11、select * from table1 where column1 like '[A]%' or like '[^B]%'
12、select @column1=column1 from table1;select @column1 as column1 '存储到自定义变量本回答被网友采纳