---
title: "3个表之间全连接"
author: "strutsliu"
date: "2011-03-04T15:11:59Z"
tags: []
categories: ["数据库"]
slug: "3"
draft: false
lastmod: "2011-03-04T15:11:59Z"
id: 940893
url: "https://strutsliu.iteye.com/blog/940893"
---

有三个表:
a (P1,P2,a,b..)
b (P1,P2,...)
c (P1,P2,...)
三个表的全连接是:
select .. from a full join b on a.p1=b.p1 and a.p2=b.p2 full join c on a.p1=c.p1 and a.p2=c.p2
还是:
select .. from a full join b on a.p1=b.p1 and a.p2=b.p2 full join c on (a.p1=c.p1 and a.p2=c.p2) or (b.p1=c.p1 and b.p2=c.p2)

哪个是对的?


第一个是a和b，a和c的全连接

第二个是a和b，a和c，b和c的全连接

所以第二个是对的

转载自http://topic.csdn.net/u/20090317/14/9cd6e12c-68d1-4bde-81b5-88cc1da1eae4.html