We will explain what are the Joins in SQL Server and some important Joins which is mostly uses in database query as (left join ,right join in sql with example) .
It is joins are used to get data from two or more tables based on relationship between some of the columns in tables. first of all use in primary key of first table and foreign key of second table to get data from tables by using this relationship i can reduce the duplication of data in every table.
Create database in your system and also create table , field name with datatype and make the primary key in first table .It is joins are used to get data from two or more tables based on relationship between some of the columns in tables. first of all use in primary key of first table and foreign key of second table to get data from tables by using this relationship i can reduce the duplication of data in every table.
step 1-pankaj(database name)
step -2 table name1(employee)
step -3 field Name
ID(primary key,int)
name(varchar)
Address(varchar)
Email_Id(varchar)
Create second table , field name with datatype and make the foriegn key in second table .
Create second table , field name with datatype and make the foriegn key in second table .
table name2(designation)
dep_id(set primary key,int)
id(foriegn key)
department(varchar)
salary(varchar)
1---Join(Sql command) show
both table's record
use pankaj(database name)
select * from employee(table
name1) join designation(table2) on employee.id=designation.id
2---Join(show particular
record both table's
select
employee.name,employee.address,employee.email_id,designation.department,designation.salary
from employee
join
designation
on employee.id=designation.id
what is defferent between
right join and left join?
Right Join:- It is taking output all items from right table AND (only) matching items from left table that is called right join.
For Example:-
For Example:-
select * from employee left
join designation on employee.id=designation.id
Left Join-It is taking output all items from left table AND (only) matching items from right table
For Example:-
select * from employee left
join designation on employee.id=designation.id
No comments:
Post a Comment