SQL,select的字段如何取别名
原⽂地址为:
SQL如何取别名
access 多表查询有重复的字段,⽽且要前台绑定,怎么办?access⽤ 列表+空格+别名可不⾏!
要这样:
SELECT product.id as productId,product.name,product.price,car.amount,car.amount*product.price as totalprice from product,car,orderlist where  berid=11 and orderlist.carId=car.Id and car.productId=product.id
其实,select列的时候取别名有三种⽅法,这三种⽅法并不是所有数据库都适⽤。
⽅法⼀、直接在字段名称后⾯加上别名,中间以空格隔开。
sql中select是什么意思⽅法⼆、以as关键字指定字段别名,as在select的字段和别名之间。
⽅法三、对于SQL Server 还提供了另外⼀种⽅法,之间⽤“=”号指定。“=”号放在select的字段和别名之间。
例⼦:
SQL Server Oracle
select Emp_Id as EmpId
, Emp_Name "Employee Name"
, Extemsion=Ext
, SUBSTRING(Emp_Id,1.2) "到职位年度" from Employee
where Dept_Id='I200'select Emp_Id as EmpId
, Emp_Name "Employee Name"
, Extemsion Ext
, SUBSTR(Emp_Id,1.2) "到职位年度" from Employee
where Dept_Id='I200'
转载请注明本⽂地址: