左外部联接和附加的where子句 [英] Left Outer join and an additional where clause
本文介绍了左外部联接和附加的where子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在定义为左外部联接的两个表上有一个联接,以便所有记录都从左表返回,即使它们在右表中没有记录也是如此.但是,我还需要在右侧表中的字段上包含where子句,但是....我仍然希望为左侧表中的每个记录返回左侧表中的一行,即使where子句中的条件不满足.有办法吗?
I have a join on two tables defined as a left outer join so that all records are returned from the left hand table even if they don't have a record in the right hand table. However I also need to include a where clause on a field from the right-hand table, but.... I still want a row from the left-hand table to be returned for each record in the left-hand table even if the condition in the where clause isn't met. Is there a way of doing this?
推荐答案
是的,将条件(称为谓词)放在连接条件中
Yes, put the condition (called a predicate) in the join conditions
Select [stuff]
From TableA a
Left Join TableB b
On b.Pk = a.Pk
-- [Put your condition here, like this]
And b.Column = somevalue
这篇关于左外部联接和附加的where子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文