Database joining

 Database joining:-

1. Joining is a special type of operation perform between 2 tables.

2. With the help of joining we get the result between multiple data.

Joining property:-

1. Common field (column)

2. Using table object

Syntax :-  table name.column name

3. To activate joining operaton we need ON KEYWORD.

ü TYPES OF JOINING:-

1. INNER JOIN  :- Inner join returns all records from multiple data where the join condition is equal.

Ex:-CREATE TABLE invent ( id INT , name VARCHAR(20));

INSERT INTO invent values(101,'rahul'),(103,'thosar'),(102,'asus');

 

CREATE TABLE product (id INT , cost int);

 

INSERT INTO product VALUES (201,'1000'),(202,'2000'),(203,'30000');

 

SELECT invent.id , invent.name, product.cost FROM invent INNER JOIN  product  ON  invent.id =product.id;  // query for inner.

 

2. LEFT OUTER  JOIN:-(matches all the left entity.)

Ex:- SELECT invent.id ,invent.name,product.cost FROM invent LEFT OUTER JOIN product ON invent.id=product.id;

 

3. RIGHT OUTER JOIN:-

Ex:-SELECT invent.id ,invent.name,product.cost FROM invent RIGHT  OUTER JOIN product ON invent.id=product.id;

 

4. FULL OUTER JOIN :-

Ex:-SELECT invent.id ,invent.name,product.costFROM invent FULL OUTER JOIN product ON invent.id=product.id;

 

5. CROSS JOIN:- (when store procedures)

Comments

Popular posts from this blog

ViewState for state management

INTRODUCTION OF C#