如何排除不与另一个表联接的行? [英] How to exclude rows that don't join with another table?

查看:73
本文介绍了如何排除不与另一个表联接的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表,一个表具有主键,另一个表具有外键.

I have two tables, one has primary key other has it as a foreign key.

仅当辅助表没有具有包含其键的条目时,我才想从主表中提取数据.类似于简单内部联接的对立面,内部联接仅返回通过该键联接在一起的行.

I want to pull data from the primary table, only if the secondary table does not have an entry containing it's key. Sort of an opposite of a simple inner join, which returns only rows that join together by that key.

推荐答案

SELECT <select_list> 
FROM Table_A A
LEFT JOIN Table_B B
ON A.Key = B.Key
WHERE B.Key IS NULL

完整的加入图片

从aticle: http://www.codeproject.com/KB/database/Visual_SQL_Joins .aspx

这篇关于如何排除不与另一个表联接的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆