Home > DeveloperSection > Blogs > JOIN in SQL Server

JOIN in SQL Server


Database Database 
Ratings:
1 Comment(s)
 2168  View(s)
Rate this:



SQL JOIN’s     


SQL JOIN's are used to query data from two or more tables, based on a relationship between certain columns in these tables.SQL joins are used to combine rows from two or more tables.

In the examples below I am going to take following two tables.

In this blog I am going to discuss about two JOIN type:

  1. INNER JOIN
  2. OUTER JOIN

INNER JOIN

The INNER JOIN keyword return rows when there is at least one match in both tables.

Example

SELECT * FROM Table1 t1

INNER JOIN Table2 t2

ON t1.ID = t2.ID

Output

OUTER JOIN

There are three types of OUTER JOIN’s

  1. LEFT OUTER JOIN
  2. RIGHT OUTER JOIN
  3. FULL OUTER JOIN

LEFT OUTER JOIN

LEFT OUTER JOIN returns all the rows from the left table in conjunction with the matching rows from the right table. If there are no columns matching in the right table, it returns NULL values.

Example

SELECT * FROM Table1 t1

LEFT OUTER JOIN Table2 t2

ON t1.ID = t2.ID

Output

RIGHT OUTER JOIN

RIGHT OUTER JOIN returns all the rows from the right table in conjunction with the matching rows from the left table. If there are no columns matching in the left table, it returns NULL values.

Example

SELECT * FROM Table1 t1

RIGHT OUTER JOIN Table2 t2

ON t1.ID = t2.ID

Output

FULL OUTER JOIN

FULL OUTER JOIN returns rows from either table when the conditions are met and returns null value when there is no match.

Example

SELECT * FROM Table1 t1

FULL OUTER JOIN Table2 t2

ON t1.ID = t2.ID

Output


how many time update row in database

By Rakesh Chavda on   2 years ago
auto   auto
id id_Char Name call city
1 R001 Ramesh 9898989898 Delhi
2 R002 kamal 9898989899 Pune
3 R003 Rutu 8585858585 Ahmadabad<--------now i m update this row with using c#.i need this data
4 R004 Raja 9898989595 second original auto id or last data at it is.
5 R003 Rutu 7878787888 Pune
6 R005 Amit 9988774455 Indor
how to it is possible ??? so i see how to any 1 data id update how many in database........  

Don't want to miss updates? Please click the below button!

Follow MindStick