In some businesses, you may need to connect the joined table to the master table to obtain the desired result. This is a bit like Conditional compilation. join is performed only when the criteria are met. If the criteria are not met, no join is performed (or the association condition fails). Environment: oracle, please refer to the Code: SQL code create table A1 (id number, val number); create table A2 (id number, type varchar2 (2), val number, anyvalue varchar2 (30); insert into a1 values (1, 50 ); insert into a1 values (1,500); insert into a1 values (2,100); insert into a1 values (2,150); insert into a1 values (3,200); insert into a1 values (3,250 ); insert into a1 values (4,150); insert into a1 values (4,500); insert into a2 values (1, '>', 100, '> 100 '); insert into a2 values (1, '<=', 100, '<= 100'); insert into a2 values (2, '<', 150, '<150 '); insert into a2 values (3, '<= ', 200,' <= 200 '); insert into a2 values (4,'> = ', 150, '> = 150'); select * from a1; select * from a2; select * from a1, a2 where a1.id = a2.id and (case a2.type when '> 'then (case when a1.val> a2.val then 1 else 0 end) when '> = 'then (case when a1.val> = a2.val then 1 else 0 end) when' <= 'then (case when a1.val <= a2.val then 1 else 0 end) when' <'then (case when a1.val <a2.val then 1 else 0 end) else 0 end) = 1; drop table a1 purge; drop table a2 purge; author czwlucky