多表查询的一些技巧
1、基本方法:From 后面可以接多個表名,表與表之間用逗號隔開,查詢字段之間要加上表的名字。
例如:Select table1.column1, table2.column1 from table1, table2
2、表別名:可以為表設(shè)置別名,以簡化輸入,方法是直接在表名后加空格,接你設(shè)定的別名。
例如:Select a.column1, b.column2 from table1 a, table2 b
3、運算:選取的過程也可以進行一些簡單運算,包括邏輯運算和數(shù)學運算。
例如:select isnull(a.column1, b.column2), case a.column2 when true then a.column3 else a.column4 from table1 a, table2 b
4、字段別名:運算結(jié)果給成的新字段是沒有字段名的,為了提取方便,最好給它們設(shè)定別名,就像給正常的字段設(shè)定別名一樣。
例如:select isnull(a.column1, b.column2) as column_status from table1 a, table2 b
轉(zhuǎn)載于:https://www.cnblogs.com/mayiyi-01/archive/2012/11/20/2778965.html
總結(jié)
- 上一篇: 高通qca-wifi移植
- 下一篇: 使用Git简单笔记