???? ID: 136699 - ????? ???????: 03 ?????? 2010 - ??????: 4.0 Microsoft Query ??? joins ?? ????? ?? ?????
?? ????? ?????????? ???? Microsoft Query ??? joins ?? ????? ?? ??? ?? ?? ????? ???? ??? ??? ????? ?? ?? ????? ?? ?? ????????? ?? ?? ?????? ?? ??? ????? illustrate ???? ?? ??? ??????? ?? ?? ????? ?? ???? ???? Microsoft Query ??? ?? ?? ???? ??? ????? ?? ??????? ?????? ?? joins ?? ??????? ????? ?? ?????? ???, Microsoft ?????? joins ???????? ??? ???? ?????? ???? ?? ???? Joins ????????? ?????? ??? ??? ?????? ?? ?????? ???? ?? ?????? ???????? ???? ???? ??? ?? ???? ??? ???????? ?????? ??? ????? ????? ???: What Is a Join? Inner Joins SQL Statements Outer Joins Subtract Joins Full Outer Joins Self Joins Equi-Joins Natural Joins Cartesian Products ???? ??????????? ??? ?????? ???? ?????? ????? ??? ???? ?? ???????? ???? ????? ?? ?????? ?? common ??? ??? ?? ??????? ???? (?? ????? ?? ???? ???? ?? ???????? ?????? ?? ??? ???) ????? ?? ?????? ???? ??? ?? ?????? ?? ??? ??? ??????? ??? ?????? ?? ???, ????? ?? ????????: ?? ???
Color_Table:
Join_Field Color_Field
1 Red
2 Blue
3 Green
Pattern_Table:
Join_Field Pattern_Field
2 Striped
3 Checkered
4 Polka-Dot
?? ?????? ????? ????? ???? ???? ??: Join_Field Color_Field Pattern_Field 2 Blue Striped 3 Green Checkered ?????? ?????? ??? ???? ?????? 2 ?? 3 Join_Field ????? ??? ?? ??????? ?? ???? ??????? ?? Color_Table ?? Pattern_Table ????? ??? ????? ???? ??? ????? ?? ?? ????????? ?????? ?? ???????? ?? ?????????? ?? ???? ?? ?? ????????; ?????? ?????? ?? ?????????? ?? ???? ?????? ?? ??? ?????? ID ?????? ????? ?? ???? Inner ????????? ????? ????? ???? ????? ?????? ??? ????? ??? simplest ?????? ?? ????? ?? ??? ????? ??, ?? ???? ???? ????? ???????? ??? ????? ?? ????? ???? ????? ???? ?????? ?? ???, ??? ?? ???????? ????? ?????, ???? ?? ???, ?? ???? ?? ?????? Join_Field, ????? ?? ??? ?? ????? ?? ???? ????? ??:Color_Field Pattern_Field Blue Striped Green Checkered Microsoft Query, ??? ????? joins ??? ????? ??????? ?????? (???? ??????? ?? ??? ????? "Microsoft Query ???????? ???????????? ???," ??????? 1.0 ????? 105)? SQL ????????? ?????? ???? (SQL) ?? ??? ???? ??? ?? ?? ?????? ?? ?????? ??? ?? ?? ???? ????? ????? ?? ????? ?? ???? ??? ??? ???? ?? SQL Microsoft Excel ?? ???? ?????? ?????? (??????????? ?? Excel 4.0 ?????? ???? ?? ??? Visual Basic) ?? ???? ????? ????? ???? ?? Microsoft Query ??? ????? ?? joins ????? ?? ??? SQL ?? ????? ?? ??? ?????? ??? ???????? ????? ??? ?? ?? ??? ???? ??? ??? ?? ??????? ??? ?? ??? ???? SELECT ??? ?? ????? ?? ??? Microsoft Query ??? ????? ????? ?? "SQL" ????? ????? Microsoft Excel ?? ?????? ???????? ?? ?? ??? ??? ?? ?????? ?? ??? ??? ??????? ???? ?? ??? ????? ?? ????? Microsoft Excel ?? ?????? ???????? ???? ?? ?????? ??? ??? ???????? ?? ????? ?? ?? ??? ?? ???? ?? ????? ???? ??? ?????? ?? ??? ???? ??? ?? ???? ?? ????? Microsoft Query ??? ??? ????? ????? ?? ??? ??: SELECT Color_Table.Color_Field, Pattern_Table.Pattern_Field FROM `c:\database`.Color_Table, `c:\database`.Pattern_Table WHERE Color_Table.Join_Field = Pattern_Table.Join_Field ????? ??? ?? ?? ??????? ?? ??? 'C:\database' ????? .MDB ?? ???? Microsoft Access ???????, ?? ?? ?? ???? ???????? ?? ?? ????? ??? ?? ???? ??? ?? ??? ????? ??? ????????? ?? ????? ????? ??? ???? ???????, ???? dBASE, Paradox ?? FoxPro, ??? ???????? ?????? ????? ????? ???? ?????? ??? ?? ?????? ??? SQL ???????? ??? ???? ???????? ??????? ?????? ?? ??? ?? ????? ????????? ??? ???? ???? ??? ?? ???? ??? SQL ???????? ????? ?????? ?? ??? ??????; ?????? ?? ???, Microsoft Access ??? ?????? ?? ??? ?? ?????? ????? ?? ?????: SELECT Color_Table.[Color_Field], Pattern_Table.Pattern_Field FROM Pattern_Table INNER JOIN Color_Table ON Pattern_Table.[Join_Field] = Color_Table.[Join_Field]; ?????? ?? ??? ?? Microsoft Access ??? ????? ???? ?? ??????? ?????? ??? ???? Microsoft Access .MDB ????? ??? ???? ??? ????? ?????? ??????? ?? ?? ?????? ??? ????? ???? ???? ??, ?? Microsoft Access SQL ??? ???? ?? ????????? ???? ?? ??? ????? ??????? Outer ?????????? ???? ?????? ?? ????? ?? ???? outer ????? ??? ???? ??? ??? outer ????? ?? ??? ?? ?? ?????? ?? ??? ?????? ?? ???? ?? ?????? ?? ??????? ???? ?????? ???? ?????? ?? ??? ???? ???? ??? ?? ??? ?? ??? ????? ???????????? ????? ???? ???? ???, ?? "null." ??? ?? ????? ???? ?? ????, ?? ??? ?? ???????? ?? ??? ??? ?? ??????? outer joins, "???? outer ?????" ?? "???? outer ?????," (????? ???? ??????? ???? ????? ?? ???????? ???-??? ?????)? ?? ?????? ??? ????? ?? ???????? ?? ????? ???? ???, ????? ?? ?? ?? ??????? outer joins:Join_Field Color_Field Pattern_Field 1 Red (NULL) 2 Blue Striped 3 Green Checkered ???? ??????? ????? ??????????? ??: Join_Field Color_Field Pattern_Field 2 Blue Striped 3 Green Checkered 4 (NULL) Polka-Dot ????? ???: ???? ????? ??? ????? ???? ???? "??" ?? ?? ???? ?? ????? ???; joins ?? ??? ?? ??? ?? ??? ??? ?? ?????? "??" ?? ????? ????? Microsoft Query ??? outer ????? ?? ????? ?????? ????? ?? ???? ????? ?? ???? ?? ????? ???? (?? ????????? ?? ???? ??? ???? ??????? ?? ??? ????? "Microsoft ?????? ?????????? ????????????," ??????? 1.0 ?? ????? 112)? ????? ?? ?? SQL ??? ?? outer ????? ?? ????? ?????? ?? ??? ????? ?? ???? ??:
SELECT Color_Table.Color_Field, Pattern_Table.Pattern_Field
FROM {oj `c:\database`.Color_Table LEFT OUTER JOIN
`c:\database`.Pattern_Table ON Color_Table.Join_Field =
Pattern_Table.Join_Field}
????? ?? ??? ??? outer ????? ?? ?? ????????? ??????, ?????? ???????? ???????? ?? ???????? ???? ??? ?? ?? ?? ???, ????? ???? excluding ???????? ???? ???? ??? ?? ?? ???????? ?? ??? ?? ????? ?? ???????? ?? ???? ?????? ??? ???? ?? ???, ?????? ?? ???? ?????? ?? ?????? ?????? ??? ????? ???? ?? ??? ???? ?????? ID ????? ?? ????? ????? Subtract ??????????? ?? ???? ????? ?????? ?? subtract ????? ??? ??? subtract ????? ?? ???? outer ????? ?? opposite ??; ?? ?????? ??? ??? ?? ?????? ?? ??? ? ???? ???? ?? ?????? ??? ???? ?? ?????? ??? ????? ??? Outer joins ?? ??? ??? ?? ???? subtract ??? ????? ???? ????? ??? ?? ???? ?? ?? ???????? ?? ??? joins; ???????, ?? ??? ???? ????? ?? ???????? ???? ?? ??? "???? ????? subtract"??"???? ????? subtract." Subtract ????? ?? ??????? ??? ?? ????? ?? ???? ??? ???????? ?? ???? ?? ?? ??????? ??????? ?????? ???? ?????? ?? ????? ?????? ???? ?? ???? ????? ??? ?? ???? ?? ????? subtract:join_Field Color_Field 1 Red ?? ????? ???? ??: Join_Field Pattern_Field 4 Polka-Dot Microsoft Query ??? ?? subtract ????? ?? ???? ?? Outer ????? ??? ??? ??, ?? ???? ??? "?? IS" ?????? ?? ????? ???? ?? ???? ?? ?? ??????? ????? (Pattern_Field ??? ???? ?????? ???; ??? ????? ?????? Color_Field) ?????? ?? ??? ?? ??? ???? ???? exclude ??????? ???? ?? ???? ????? ?? ?? SQL ??? ??? ???? subtract ????? ?? ??? ????? ?? ???? ??:
SELECT Color_Table.Join_Field, Color_Table.Color_Field
FROM {oj `c:\database`.Color_Table LEFT OUTER JOIN
`c:\database`.Pattern_Table ON Color_Table.Join_Field =
Pattern_Table.Join_Field}
WHERE (Pattern_Table.Pattern_Field Is Null)
????? ?? ??? ??? subtract ?????, ?? ??? ?? ??? ???? ???? ???? ?? ???? ???????? ?? ???? ??? ?? ?? ????????? ??????? ??? ???? ?? ???, ??? ?????? ???? ?? ?? ???? ?????? ??? ????? ???? ?? ??? ??? ???? ID ????? ?????? ????? Outer ??????????? ?? ???? ???? ?????? ?? ????? outer ????? ??? ??? ????? outer ????? ??? ???? ???????? subtract ????? ?? ??? ??? outer ????? ?? ?? ?????? ??? ??? ????? outer ????? ????? ???????? ?? ????????? ?? ??? ????? ??? ?? ?? ?????? ?? ??? ??????? ??? ?? ?? ?????? ???? ???? ??? ??? ????? outer ????? ????? ??:Join_Field Color_Field Pattern_Field 1 Red (NULL) 2 Blue Striped 3 Green Checkered 4 (NULL) Polka-Dot Microsoft Query ??? ??? ????? outer ????? ?? ??? ???? ??? outer ????? ?? subtract ????? ?? ??? ???? ??? (????? ???) ?? ??? ??? ?????? ?? UNION ?????? ???????? ???? ?? ?? ???? ??? ????? ?? ??? ??? ????? outer ????? Microsoft Query ???, ??????? SQL ????? ?? ????? ?? ??? ????? ????? ?? ????? ????:
Join_Field Color_Field Pattern_Field
(NULL) Polka-Dot
1 Red (NULL)
2 Blue Striped
3 Green Checkered
???? ???? SQL ??? ????? outer ????? ?? ??? ????? ?? ???? ?? (???? ???? UNION ?????? ??????? ???? ??):
SELECT Color_Table.Join_Field, Color_Table.Color_Field,
Pattern_Table.Pattern_Field
FROM {oj `C:\database`.Pattern_Table LEFT OUTER JOIN
`C:\database`.Color_Table ON Color_Table.Join_Field =
Pattern_Table.Join_Field}
UNION
SELECT Color_Table.Join_Field, Color_Table.Color_Field,
Pattern_Table.Pattern_Field
FROM {oj `C:\database`.Color_Table LEFT OUTER JOIN
`C:\database`.Pattern_Table ON Color_Table.Join_Field =
Pattern_Table.Join_Field}
WHERE (Color_Table.Color_Field Is Null) or(Pattern_Table.Pattern_Field Is Null)
????? ?? ??? ??? ????? outer ????? ?? ?? ????????? ??????, ???? ?????????? ?????? ??????? ????? departments, ?????? ??????? (?? ???? ???? ?? ???? ??), ?? ??????? ?-??? ??? (?? ????? ???? ??? ???? ???) ?????? ????? ???? ???? ??? ?? ????? ?????, joined ???? ?????? ???? ???? ??? ???? ????? ???? ?? ????? ???? ?? ??? ???? ?? ???? ??? ?? ?? ?????? ID ?????? ?? ????? ?? ???? Self-Join??? ??????? ?????? ?? ????? ?? self-join ??? ??? self-join ?? ?? ??????? ??? ?? ???? ??? ?????? ???? ?????? ??? ??? ?? ??? ?? ?? ?????? ?? ?? ????????? ???? ???? ????? ?? ???? ?? ?????? ?????? ?? ????? ????:
Table_Three
Employee_ID Employee_Name Reports_To
1 Bob 3
2 Sue (NULL)
3 Jim 2
4 Jane 3
?? follows ?? ??? ???, ?? ?? ?????????:
Table_Three_01
Employee_ID Employee_Name Reports_To
1 Bob 3
2 Sue (NULL)
3 Jim 2
4 Jane 3
??? self-join ????? ???? ?? ??? ???? ???????? ??? ?? ??? ???????? ????? ?? ???? ????? ?? ???? Table_Three ??? Employee_ID Table_Three_01 ??? Reports_To ?? ??? ????? ?? ???? ??? ????? ?? ?? ?? ?? ???? ?? ?? ????? ?????: Employee_Name Employee_Name Bob Jim Sue (NULL) Jim Sue Jane Jim ???????, ????? ????????? ?? ??? ?? ?? ????? ??? ?? ??? confusing ??, ??????? ????????? ?? ????? ??? ???????????: Employee_Name Supervisor Bob Jim Sue (NULL) Jim Sue Jane Jim ????? ?? ?? SQL ?? ???? ?? ????? ?? ??? self-join: SELECT table_three.Employee_Name, table_three_01.Employee_Name 'Supervisor' FROM `c:\database`.table_three, `c:\database`.table_three_01 WHERE table_three.Employee_ID = table_three_01.Reports_To ?? ?? Microsoft Excel ??? ???? ???? ??, ?? Microsoft Query ??? ????? ?? ??? ????? ?? ????? ???? ?? ??? ?? ???? ?? ??????? Microsoft Excel ??? ????? ??? ?? ????? ???? ??? ?? ?????? ?? ???? ??? ???? ??????? ?? ??? ????? ?????????? ???? ?? Microsoft ???????? ??? ?????: 121551 (http://support.microsoft.com/kb/121551/EN-US/ ) : XL5: Excel ??? ???? MSQUERY ??? ????? ??? ?? ???? ????? ?? ??? ?? ???? ???? ?? (??? ?? ???? PivotTable, ?? ???? ??? ?? ??? ???? ????? ????? ?? ????? ????? ?? ??? ???? ??? ???? ????) Microsoft Excel ?? ???? ?????? ????? ?? ??? ????? ????? Equi ?????? ?? ?????? ?????????? ??? joins, ??? ??, ??? ?? ??? ?????? ???? equi joins ?? ????????? joins ???? ?? ?????? ?? meanings Microsoft ?????? ?? ??? ?????????? ?? ??? ?? ?? ?? significance ?? ???, ????? ???? ?? ?????????? ?? ??? curious ?? ???? ?? ?? ?? ?????? ?? ?????? ?? ?????? ???? ???Equi ????? ?? ?? ????? ??? ???-?? ?????? ??? ??????? ?? ????? ?????? ??? ???? ??? ??? ?? ????? ???????? ?? ?????? ??? ?? ???? ???? ??????? ???? ????? ?? ??? ?????? ?? ???? ??, ????? ?? ???? ??? ?? ???-????? ????? ?? ?? ?????? ?? ?? ????? ???? ???? ?????? ??? ?????? ????? ?????? ??? ?? ??????? ???? ?? ??? ????? ??? ???? ???? ?????? ??? joined ????? ?? ???? ?? (?? ???? ?? ?????) joined ????? ?????? ??? ????? (?? ???? ?? ?? ?????, ?? anything besides ?? ?????)? Naturally, ?? equi-????? ?? ???? ?????? ???? ?? ??? ?? ????????? ????? ?? ?????? ?? ?? ???????? joined ?????? ??? ???? ?? ???? ??? ?? ?? ????? ??????? ????? equi-????? ??? ?? ???, ??????? ??? ???????? ????? ????? ???? ??? ???-????? ??? ????? ?? ??? ?? ????????? ?? ????? ????? ???? ?????? ??? ?????, equi joins ?? ????????? joins ???? ?? ???? ???? ???? ????? ??? ?? equi-joins (?????? ??????? joins ?? ????? ???? ?? ??) ???? ?? joined ?????; ???? ?? ?? ????????? ????? ?? ???? ??, ????? ??? ???? ??? ???? ???-????? ????? ?? ????? ????, ?? ???? ?? ?? ????? ??? ??? ????? joined ??????? ?? ???? ?? ?? ?? ???-????????? ????? ????? ?? ???? ???? ?????? ?? joins ???? Joins ?? ????? spectrum 1992 ??? ???? ??? ?? ??? ????????? ???? ??? ?? ?? ?? ???? SQL 92 ?? ??? ??? ???? ???? ??? ??? joins Microsoft Excel ?????????? ?? ??? ?????????? ???? ??? ??????? ?? joins ???? ????? ??? ?? Microsoft Excel ??? ???? ???? ?? ??? ???? ??? ??? ???? Cartesian ?????????? ?? ?? "Cartesian ??????." ??? ???? ?? ????? ?? ???? ?? ???? ???? ?? joins ?? ?? ???? ???????? ?? ????? ?? ??? ?? ?????? ?? ??? ?? ??? Cartesian ?????? ??? ???????? ??? ????????? ?? ??? ??????? ?????? ?? ??? ??? ???????? ?? ???? ??? ????????? ???? ?? ???? ??/?? ?? ?????? ???? ???????? ?? ???? ???????? ?? Cartesian ?????? ?? ???? ???? ?? ??? ?? ???? ?? ???? ??????? ????, ?? ???? ???? ?? ??? ?????? ???? ?? ???? joins ?? ?? ???? ??? ????? ?? ?? Cartesian ?????? ?? ??? ??? ?? ?????? ???????? ?? ????? ???? ???; ????? ??? ?? ?? ?????? ?? ???? 3 ?? ??????? ??? 3 ??????, ?? ??? 9 ?????? yields ??? ???????, ??? ???? ????, ?????? ?? 100 ??????? ??? 1,000 ??????? ??? 10000 ??????; ?? ?? ?????? 1,000,000,000 ?????? ??? ?? ???? imagine!Join_Field Join_Field Color_Field Pattern_Field 1 2 Red Striped 1 3 Red Checkered 1 4 Red Polka-Dot 2 2 Blue Striped 2 3 Blue Checkered 2 4 Blue Polka-Dot 3 2 Green Striped 3 3 Green Checkered 3 4 Green Polka-Dot ???-???, ??? ?????????? ??? Cartesian ?????? ?? ????? ???? ????? ??; ???????, ?????? ??????? ???? ???? ??????? ???????????? ??? ??????????, ?? ????? ?????? ?????? confused. ??????? ???????????? ?? ???? ????? ??? ????? ?? ??????? ?? ???? ???, ??????? ?? ???????? Cartesian ?????? ?? ???? ??? ????? ?? ????? ?? ?? ??? ??? perplexing: Color_Field Red Red Red Blue Blue Blue Green Green Green ??? 100 ?????? Pattern_Table ??? ???? ???? ???, ?? ?????? 309 ?????? (103 ?????? ???????? ???, ???? ?? ??? ??) ?? ???? ??? Cartesian ???????? ?? ??? ?????????? ?????? ????? ?? ??? ????? ????? ?? ?? SQL ??? Cartesian ?????? ?? ??? ????? ?? ???? ??: SELECT Color_Table.Color_Field, Pattern_Table.Pattern_Field FROM `c:\database`.Color_Table, `c:\database`.Pattern_Table ???????? ?????? ?? ??? ????? ??? ?? ??? ?? ??? ??????? ?????? merchandise ??? ?????? ?? ???????? ?? ???? ????? ?? ??? ??? Cartesian ?????? ?? ?? ????????? ?????? ?? ???? ??? ??????Microsoft Query "?????????? ????????????," ??????? 1.0, 101-114, 123-131 ????? ????? ?? ???????? ???? ?? Microsoft ?? ??? ????? ???? ??? ??????? ???????? ?? ???? ???? ?? Microsoft ??????? ???? discussed ?????-???? ?????? Microsoft ?? ???????? ???? ?????????? ?? ?????? ???? ???? ???; ?? ??? ?? ??????, ?????????? ?? ???? ???? ?? ???????? ????? ???????? ?? ??????????? ?? ???? ??? ??? "??? SQL ?? ?????: ??? ????? ????????????" Morgan Kaufmann ???????, Inc., 1993? "Smarties ?? ??? ?? Celko ?? SQL: SQL ????????????, ?????" Morgan Kaufmann ???????, Inc., 1995? Microsoft Query ??? joins ????? ?? ???? ??? ???? ??????? ?? ??? ??? ????? ??? ?????? ?? ?????? ???: joins, overview ???? ???? ???? ??:
???? ?????? ??????????????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??. ?????????? ?? ??????? ????????? ??????? ??:136699
(http://support.microsoft.com/kb/136699/en-us/
)
| ???? ?????? ???? ?????? ??????
????????? ?????? ??????? ???????? ??????
|






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email

????? ?? ???? ????
