key words: 表連接
內(nèi)連接
select statement from table1 join table2 on table1.fieled1 = table2.field2
select statement from table1 ,table2 where table1.field1 = table2.field2
左連接
select .....table1 left outer join table2 on table1....= table2.field
select .... table1 ,table2 where table1.field1= table2.field(+)
合并查詢
union:獲得并集,并自動(dòng)去掉重復(fù)行,并且會(huì)以第一列的結(jié)果進(jìn)行排序
union all: 獲得并集,但不去掉重復(fù)行,也不排序
子查詢:
對(duì)于多行子查詢,必須要用多行運(yùn)算符(IN,NOT IN,EXISTS,NOT EXISTS,ALL,ANY)
內(nèi)連接
select statement from table1 join table2 on table1.fieled1 = table2.field2
select statement from table1 ,table2 where table1.field1 = table2.field2
左連接
select .....table1 left outer join table2 on table1....= table2.field
select .... table1 ,table2 where table1.field1= table2.field(+)
合并查詢
union:獲得并集,并自動(dòng)去掉重復(fù)行,并且會(huì)以第一列的結(jié)果進(jìn)行排序
union all: 獲得并集,但不去掉重復(fù)行,也不排序
子查詢:
對(duì)于多行子查詢,必須要用多行運(yùn)算符(IN,NOT IN,EXISTS,NOT EXISTS,ALL,ANY)