SQL Join
SQL Join Example One - A "Natural" Join
Select Thespian_Film_Table.Film_Title, Film_Year
From Thespian_Film_Table,
Film_Table
Where Thespian_Last_Name equals "Garland"
and Thespian_First_Name equals "Judy"
and Thespian_Film_Table.Film_Title = Film_Table.Film_Title;
Andy Hard Meets Debutante, 1940 Babes in Arms, 1939 Babes on Broadway, 1941 A Child is Waiting, 1963 Clock - The, 1945 Easter Parade, 1948 Everybody Sing, 1938 For Me and my Gal, 1942 Girl Crazy, 1943 Harvey Girls - The, 1946 I Could Go on Singing, 1963 In the Good Old Summertime, 1949 Judgement at Nuremberg, 1961 Life Begins for Andy Hardy, 1941 Listen - Darling, 1938 Little Nelly Kelly, 1940 Love Finds Andy Hardy, 1938 Meet Me in St. Louis, 1944 Pirate - The, 1948 Presenting Lily Mars, 1943 Star is Born - A, 1954 Strictly G.I., 1944 Strike Up the Band, 1940 Thoroughbreads Don't Cry, 1937 Thousands Cheer, 1943 Till the Clouds Roll By, 1946 Wizard of Oz - The, 1939 Ziegfield Follies, 1946 Ziegfeld Girl, 1941
SQL Join Example Two - A Subselect
Select Film_Title, Film_Year
From Film_Table
Where Film_Title in
(Select Film_Title
From Thespian_Film_Table
Where Thespian_Last_Name equals "Garland"
and Thespian_First_Name equals "Judy");
Andy Hard Meets Debutante, 1940 Babes in Arms, 1939 Babes on Broadway, 1941 A Child is Waiting, 1963 Clock - The, 1945 Easter Parade, 1948 Everybody Sing, 1938 For Me and my Gal, 1942 Girl Crazy, 1943 Harvey Girls - The, 1946 I Could Go on Singing, 1963 In the Good Old Summertime, 1949 Judgement at Nuremberg, 1961 Life Begins for Andy Hardy, 1941 Listen - Darling, 1938 Little Nelly Kelly, 1940 Love Finds Andy Hardy, 1938 Meet Me in St. Louis, 1944 Pirate - The, 1948 Presenting Lily Mars, 1943 Star is Born - A, 1954 Strictly G.I., 1944 Strike Up the Band, 1940 Thoroughbreads Don't Cry, 1937 Thousands Cheer, 1943 Till the Clouds Roll By, 1946 Wizard of Oz - The, 1939 Ziegfield Follies, 1946 Ziegfeld Girl, 1941
Also Note: Both methods of joining tables should give the same results. The natural join is more CPU efficent on most SQL platforms.
One More Note: You can see the syntax for subselect on our subselect page.
| Comments Comments are left by visitors to FluffyCat.com, are not endorsed by FluffyCat.com, and may or may not be accurate. |
| Comment by TheMadProfessor Rate this Comment |
Another way now available to do joins is with the JOIN keyword. For example, the above select could have been written as:
|
| Sign In |
| to add your own comment |