background preloader

Visual Representation of SQL Joins

Visual Representation of SQL Joins
Introduction This is just a simple article visually explaining SQL JOINs. Background I'm a pretty visual person. Things seem to make more sense as a picture. Using the code I am going to discuss seven different ways you can return data from two relational tables. For the sake of this article, I'll refer to 5, 6, and 7 as LEFT EXCLUDING JOIN, RIGHT EXCLUDING JOIN, and OUTER EXCLUDING JOIN, respectively. Inner JOIN This is the simplest, most understood Join and is the most common. Hide Copy Code SELECT <select_list> FROM Table_A A INNER JOIN Table_B B ON A.Key = B.Key Left JOIN This query will return all of the records in the left table (table A) regardless if any of those records have a match in the right table (table B). SELECT <select_list>FROM Table_A A LEFT JOIN Table_B B ON A.Key = B.Key Right JOIN This query will return all of the records in the right table (table B) regardless if any of those records have a match in the left table (table A). Outer JOIN Left Excluding JOIN Examples History

QuickRef.org - all your docs are belong to us - PHP, Perl, CSS, HTML, Java, JavaScript, MySQL, Ruby, Python, and more

Related: