基本上我的疑问是,如果我们在LEFT OUTER JOIN的ON子句中指定条件,或者我们在WHERE 子句中使用空检查指定条件,是否相同?
表架构:
Create table App(ID number , STATUS varchar2(10));
Create table App_Child(child_id number ,
STATUS varchar2(10),
ID number );
查询 1
SELECT a.ID AS appID, a.STATUS AS appSTATUS,
b.child_id AS acOWNID,b.STATUS AS acSTATUS, b.id AS acID
FROM App a LEFT OUTER JOIN App_Child b ON (a.id=b.id AND b.STATUS <> 'disabled') WHERE a.ID = ?;
查询 2
SELECT a.ID AS appID, a.STATUS AS appSTATUS,
b.child_id AS acOWNID,b.STATUS AS acSTATUS, b.id AS acID
FROM App a LEFT OUTER JOIN App_Child b ON (a.id=b.id) WHERE a.ID = ? AND (b.STATUS IS NULL OR b.STATUS<>'disabled');