Saturday, 30 December 2017
Wednesday, 20 December 2017
Tuesday, 19 December 2017
Tuesday, 12 December 2017
Thursday, 30 November 2017
Learn Sql Server in 60 Days - Day 10 ( Inner Join in Sql server)
CREATE DATABASE demo_oueter_join
go
USE demo_oueter_join
go
CREATE TABLE company
(
companyid INT IDENTITY(1, 1),
NAME VARCHAR(100)
)
CREATE TABLE department
(
departmentid INT IDENTITY(1, 1),
NAME VARCHAR(100)
)
CREATE TABLE employeedetail
(
employeeid INT IDENTITY(1, 1),
employeename VARCHAR(100),
departmentid INT,
companyid INT
)
go
SELECT *
FROM company
SELECT *
FROM department
SELECT *
FROM employeedetail
go
INSERT INTO company
(NAME)
SELECT 'A'
UNION
SELECT 'B'
INSERT INTO department
(NAME)
SELECT 'X'
UNION
SELECT 'Y'
INSERT INTO employeedetail
(employeename,
departmentid,
companyid)
SELECT 'Paul',
1,
3
UNION ALL
SELECT 'Sam',
2,
2
go
--Inner join :
--select * from
--
--
--
--on
SELECT emp.employeeid,
emp.employeename,
Cmp.NAME [companyName],
dept.NAME [Department Name]
FROM employeedetail emp
INNER JOIN company cmp
ON emp.companyid = cmp.companyid
Wednesday, 29 November 2017
Learn Sql Server in 60 Days - Day 9 ( Inner Join in Sql server)
create database test_demo1
go
use test_demo1
go
create table Company (companyId int identity(1,1),Name varchar(100))
create table Department (departmentId int identity(1,1),name varchar(100))
create table EmployeeDetail (employeeId int identity(1,1),employeeName varchar(100), departmentId int ,companyId int)
go
select * from Company
select * from Department
select * From EmployeeDetail
go
insert into Company(Name)
select 'A'
union
select 'B'
insert into Department(Name)
select 'X'
union
select 'Y'
insert into EmployeeDetail
(
employeeName,
departmentId,
companyId)
select 'Shrikant',1,1
union all
select 'Sam',2,2
go
--Inner join :
--select * from
--<tab1 name> <alias>
--<join type >
--<tab2 name> <alias>
--on <condition>
select emp.employeeId,emp.employeeName,Cmp.Name [companyName] ,dept.name [Department Name] from
EmployeeDetail emp
inner join
Company cmp
on emp.companyId=cmp.companyId
inner join
Department dept
on emp.departmentId=dept.departmentId
Monday, 20 November 2017
Thursday, 16 November 2017
Tuesday, 14 November 2017
Monday, 13 November 2017
Thursday, 9 November 2017
Tuesday, 7 November 2017
Monday, 6 November 2017
Sunday, 5 November 2017
Friday, 3 November 2017
Thursday, 2 November 2017
Wednesday, 1 November 2017
Tuesday, 31 October 2017
Thursday, 26 October 2017
Wednesday, 25 October 2017
Tuesday, 24 October 2017
Monday, 23 October 2017
Tuesday, 17 October 2017
Friday, 13 October 2017
Thursday, 12 October 2017
Wednesday, 11 October 2017
Tuesday, 10 October 2017
Thursday, 5 October 2017
Wednesday, 4 October 2017
Tuesday, 3 October 2017
Monday, 2 October 2017
Wednesday, 27 September 2017
Wednesday, 23 August 2017
Subscribe to:
Posts (Atom)
-
When SQL Server executes a query it uses a query plan to determine how to access data and complete the query. SQL Server offers DBAs and d...