tags:

views:

66

answers:

3

Please explain me Joins in simple language? please do not post the weblink as i need how a developer gets it not how the author.. pls understand :)

+6  A: 

Best I can point you to is A Visual Explanation of SQL Joins.

The diagrams helped me a lot.

Josh K
+1, I must admit, the link and the diagrams are extremely resourceful and also not to mention, pretty.
Anthony Forloney
Now thats what I call good weblink.... Thanks Josh
OM The Eternity
Very useful diagrams. Wish I had that years ago.
Echiban
Thank you , Much useful
Mostafa
+2  A: 

Given Table Person And Information

SELECT *
FROM Person INNER JOIN
Information ON Person.ID = Information.ID

Will only return rows from both tables where both tables have the same IDs. So only if the ID exists in both Person and Information will the row be returned.

SELECT *
FROM Person LEFT JOIN
Information ON Person.ID = Information.ID

Will return all rows from Person, and only those that match from Information, where it does not match, it will return NULLs

SELECT *
FROM Person LEFT JOIN
Information ON Person.ID = Information.ID
WHERE Information.ID IS NULL

Will return all rows from Person that DOES NOT HAVE an entry in Information. This shows you the list of persons that do not have their Informaton updated yet.

astander
+2  A: 

I'm interpreting your question to mean joins in a very general sense, not each type of join, so if this is off the mark then I apologize:

Basically, joins enable you to get data from multiple tables in a single query by adding columns to your result set. So if you had the following tables:

Books   (ID, Title, AuthorID)
Authors (ID, Name)

You could get a result set that looked like this:

  Book                    |   Author
'The Sirens of Titan'     | 'Kurt Vonnegut'
'The Old Man and the Sea' | 'Earnest Hemingway'

By joining the two tables together like so:

select Books.Title as Book, Authors.Name as Author
from Books
inner join Authors on Authors.ID = Books.AuthorID

An inner join is the simplest type of join; it may be difficult to understand the point of outer joins without first having a strong grasp of inner joins and their uses.

Ian Henry