Wednesday, May 30, 2007

SQL Inner Join, Left Join and Right Join

Below is a Example for SQL inner join, SQL Left Join and SQL Right Join.

GuestIDName
1001Nick
1002Jack
1003Apple
Table A

ProductGuestID
Table1002
Chair1003
Almari1002

Table B

SQL inner join
Example for SQL inner join
- Join more than 1 table to get other table data
1. SELECT A.Name, B.Product FROM A INNER JOIN B ON A.GuestID=B.GuestID
Result :


NameProduct
JackTable
AppleChair
JackAlmari

2. SELECT A.Name, B.Product FROM A INNER JOIN B ON A.GuestID=B.GuestID WHERE B.Product = 'tABLE'


Result:
NameProduct
JackTable

6 comments:

Rajiv said...

hi
Actually I have used joins several times, still i was confusing number records. with example i doubt cleared, thanks for the post

Rishi Sharma said...

Sir,

Thanks for this article. But Could you publish a article with Equi, Natural and Self joins?


Thanks in advance

Rishi Sharma said...

Sir,

Thanks for this article. But Could you publish a article with Equi, Natural and Self joins?


Thanks in advance

hussainroyal said...

Good work also use this link have easy example http://codingresolved.com/discussion/233/inner-join-query-in-sql-server-example

fgdg said...

Henceforth will I recognize that each day I am tested by life Sell RS Gold in like manner. If I persist, if I continue to try, if I continue to charge forward, I will succeed Sell RS Gold, Your future depends on your dreams. So go to sleep.Do not keep anything for a special occasion, because every day that you live is a SPECIAL OCCASION Sell Runescape Gold, he time of life is short ; to spend that shortness basely, it would be too long.

fgdg said...

The consequences of today are determined by the actions of the past scarlet blade gold. To change your future, alter your decisions today scarlet blade gold, Experience is a hard teacher because she gives the test first, the lesson afterwards scarlet blade gold, but it takes character to keep you there.