Click here to Skip to main content
15,898,538 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to remove duplicate value in sql using inner join or left outer join...


ex:

select e.name,e.description,t.mobile ,m.address from employee e left outer join dept t on e.id=t.id left outer join mail m on m.id1=e.id1


ans:

employee dept mail
********......*****....*****

id..id1.. name||id..descr||id1..address||

1.. 1 ... sek ||1...chenn||.1... kovil
2.. 2 ....ram ||2...ramm ||.2....stree


ans coming


sek..chenn..kovil
sek..rammm..stree
ram..chenn.kovil
ram..rammm.stree

i dont want duplicate value
Posted

Use Select-Distinct clause (see[^]).
 
Share this answer
 
Please check this code

SQL
DECLARE @Employee TABLE
(
  ID int, 
  ID1 int, 
  Name nvarchar(10)
)
INSERT INTO @Employee VALUES(1,1,'Sek')
INSERT INTO @Employee VALUES(2,2,'Ram')

DECLARE @Dept TABLE
(
  ID int, 
  [Description] nvarchar(10),
  Mobile int
)
INSERT INTO @Dept VALUES(1,'Chenn',1234567891)
INSERT INTO @Dept VALUES(2,'Ramm',1234567891)

DECLARE @Mail TABLE
(
  ID1 int, 
  [Address] nvarchar(10)
)
INSERT INTO @Mail VALUES(1,'kovil')
INSERT INTO @Mail VALUES(2,'stree')


Select e.Name,t.description,t.mobile ,m.address 
FROM @employee e 
	LEFT OUTER JOIN @Dept t on e.id=t.id 
	LEFT OUTER JOIN @Mail m on m.id1=e.id1
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900