select a.c,b.b from (select 3 as a, 3 as c from dual
union all
select 2 as a, 1 as c from dual
union all
select 1 as a, 2 as c from dual) a
left join
(
select 3 as a,'' as b from dual
union all
select 2 as a, 'a' as b from dual
union all
select 4 as a, 'a' as b from dual) b
on (a.a=b.a)
where b.b='a'; --过滤 b 再inner join a
select a.c,b.b from (select 3 as a, 3 as c from dual
union all
select 2 as a, 1 as c from dual
union all
select 1 as a, 2 as c from dual) a
left join
(
select 3 as a,'' as b from dual
union all
select 2 as a, 'a' as b from dual
union all
select 4 as a, 'a' as b from dual) b
on (a.a=b.a and b.b='a'); --过滤 b 表 再left join a
select a.c,b.b from (select 4 as a, 3 as c from dual
union all
select 2 as a, 1 as c from dual
union all
select 1 as a, 2 as c from dual) a
left join
(
select 3 as a,'' as b from dual
union all
select 2 as a, 'a' as b from dual
union all
select 1 as a, 'a' as b from dual) b
on (a.a=b.a)
where a.c=3; --过滤 a 表 再left join b
select a.c,b.b from (select 4 as a, 3 as c from dual
union all
select 2 as a, 1 as c from dual
union all
select 1 as a, 2 as c from dual) a
left join
(
select 3 as a,'' as b from dual
union all
select 2 as a, 'a' as b from dual
union all
select 1 as a, 'a' as b from dual) b
on (a.a=b.a and a.c=3); --只对 a.c=3 的a表字段进行 left join b表的操作
union all
select 2 as a, 1 as c from dual
union all
select 1 as a, 2 as c from dual) a
left join
(
select 3 as a,'' as b from dual
union all
select 2 as a, 'a' as b from dual
union all
select 4 as a, 'a' as b from dual) b
on (a.a=b.a)
where b.b='a'; --过滤 b 再inner join a
select a.c,b.b from (select 3 as a, 3 as c from dual
union all
select 2 as a, 1 as c from dual
union all
select 1 as a, 2 as c from dual) a
left join
(
select 3 as a,'' as b from dual
union all
select 2 as a, 'a' as b from dual
union all
select 4 as a, 'a' as b from dual) b
on (a.a=b.a and b.b='a'); --过滤 b 表 再left join a
select a.c,b.b from (select 4 as a, 3 as c from dual
union all
select 2 as a, 1 as c from dual
union all
select 1 as a, 2 as c from dual) a
left join
(
select 3 as a,'' as b from dual
union all
select 2 as a, 'a' as b from dual
union all
select 1 as a, 'a' as b from dual) b
on (a.a=b.a)
where a.c=3; --过滤 a 表 再left join b
select a.c,b.b from (select 4 as a, 3 as c from dual
union all
select 2 as a, 1 as c from dual
union all
select 1 as a, 2 as c from dual) a
left join
(
select 3 as a,'' as b from dual
union all
select 2 as a, 'a' as b from dual
union all
select 1 as a, 'a' as b from dual) b
on (a.a=b.a and a.c=3); --只对 a.c=3 的a表字段进行 left join b表的操作