SQL中Alias的使用

数据库中往往过长的表名会对我们数据统计造成困扰,出现一定程度上的时间浪费

别名关键字是as

  1. 用作表的别名

举个例子,

select * from table_name as tableone 

这里把 表名table_name 改为tableone

      2.用作列的别名

举个例子,

select column_name as columnone from table_name

这里把表名column_name 改为 columnone

      3.进阶

举个例子,超过两个表格别名就显得很便捷

select po.columnone ,po.columntwo ,pt.columnone ,pt.columntwo 

from tableone as po ,tabletwo as pt

where po.columnone='数据1' and pt.columnone='数据2'

大部分的as可以省略

select po.columnone ,po.columntwo ,pt.columnone ,pt.columntwo 

from tableone  po ,tabletwo  pt

where po.columnone='数据1' and pt.columnone='数据2'

 

你可能感兴趣的:(小笔记)