INNER JOIN連接兩個(gè)表、三個(gè)表、五個(gè)表的SQL語(yǔ)句

2013-04-14 15:13:11來(lái)源:西部e網(wǎng)作者:

SQL INNER JOIN關(guān)鍵字表示在表中存在至少一個(gè)匹配時(shí),INNER JOIN 關(guān)鍵字返回行。

SQL INNER JOIN關(guān)鍵字表示在表中存在至少一個(gè)匹配時(shí),INNER JOIN 關(guān)鍵字返回行。

1、連接兩個(gè)數(shù)據(jù)表的用法:

FROM Member INNER JOIN MemberSort ON Member.MemberSort=MemberSort.MemberSort

語(yǔ)法格式可以概括為:

FROM 表1 INNER JOIN 表2 ON 表1.字段號(hào)=表2.字段號(hào)

2、連接三個(gè)數(shù)據(jù)表的用法:

FROM (Member INNER JOIN MemberSort ON Member.MemberSort=MemberSort.MemberSort) INNER JOIN MemberLevel ON Member.MemberLevel=MemberLevel.MemberLevel

語(yǔ)法格式可以概括為:

FROM (表1 INNER JOIN 表2 ON 表1.字段號(hào)=表2.字段號(hào)) INNER JOIN 表3 ON 表1.字段號(hào)=表3.字段號(hào)

3、連接四個(gè)數(shù)據(jù)表的用法:

FROM ((Member INNER JOIN MemberSort ON Member.MemberSort=MemberSort.MemberSort) INNER JOIN MemberLevel ON Member.MemberLevel=MemberLevel.MemberLevel) INNER JOIN MemberIdentity ON Member.MemberIdentity=MemberIdentity.MemberIdentity

語(yǔ)法格式可以概括為:

FROM ((表1 INNER JOIN 表2 ON 表1.字段號(hào)=表2.字段號(hào)) INNER JOIN 表3 ON 表1.字段號(hào)=表3.字段號(hào)) INNER JOIN 表4 ON Member.字段號(hào)=表4.字段號(hào)

4、連接五個(gè)數(shù)據(jù)表的用法:

FROM (((Member INNER JOIN MemberSort ON Member.MemberSort=MemberSort.MemberSort) INNER JOIN MemberLevel ON Member.MemberLevel=MemberLevel.MemberLevel) INNER JOIN MemberIdentity ON Member.MemberIdentity=MemberIdentity.MemberIdentity) INNER JOIN Wedlock ON Member.Wedlock=Wedlock.Wedlock

語(yǔ)法格式可以概括為:

FROM (((表1 INNER JOIN 表2 ON 表1.字段號(hào)=表2.字段號(hào)) INNER JOIN 表3 ON 表1.字段號(hào)=表3.字段號(hào)) INNER JOIN 表4 ON Member.字段號(hào)=表4.字段號(hào)) INNER JOIN 表5 ON Member.字段號(hào)=表5.字段號(hào)

關(guān)鍵詞:JOINSQL

贊助商鏈接: