PostgreSQL tests the effect of the left join condition with a null value

tempa table

tempb table

1. tempa left join tempb related query needs to add records with the same work order serial number

select * from tempa a left join tempb b on a."需求新增工单流水号"=b."需求新增工单流水号";

 

2. Add where a. "Requirements to add work order serial number" is not null; as a condition

select * from tempa a left join tempb b on a."需求新增工单流水号"=b."需求新增工单流水号" where a."需求新增工单流水号" is not null;

 

3. Add and a. "Requirements to add work order serial number" is not null; as a condition

 
select * from tempa a left join tempb b on a."需求新增工单流水号"=b."需求新增工单流水号" and a."需求新增工单流水号" is not null;

 

4. Add where b. "Requirements to add work order serial number" is not null; as a condition

select * from tempa a left join tempb b on a."需求新增工单流水号"=b."需求新增工单流水号" where b."需求新增工单流水号" is not null;

 

5. Add and b. "Requirements to add work order serial number" is not null as the condition

select * from tempa a left join tempb b on a."需求新增工单流水号"=b."需求新增工单流水号" and b."需求新增工单流水号" is not null;

 

6. Change left join to inner join

select * from tempa a inner join tempb b on a."需求新增工单流水号"=b."需求新增工单流水号";

The blank lines are gone and will not match

Guess you like

Origin blog.csdn.net/londa/article/details/109011567