Click here to Skip to main content
15,867,834 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
SELECT Emp.EmpName,Emp.Empid,LeaveID,StartDate,EndDate,Reason,Status FROM Emp,Leave,ReportingAuthority Where (Emp.EmpID = Leave.EmpID) AND(Emp.AuthorityID =  ReportingAuthority.AuthorityID) AND(ReportingAuthority.LoginID='MBS1984')

the Answer:

dsvd    83  17  2013-02-07 00:00:00.000 2013-02-09 00:00:00.000 sick    NULL
dsvd    83  18  2013-02-08 00:00:00.000 2013-02-09 00:00:00.000     NULL
dsvd    83  18  2013-02-08 00:00:00.000 2013-02-09 00:00:00.000     NULL
dsvd    83  19  2013-02-08 00:00:00.000 2013-02-12 00:00:00.000 sick    NULL
dsvd    83  19  2013-02-08 00:00:00.000 2013-02-12 00:00:00.000 sick    NULL
Bala    82  16  2013-02-07 00:00:00.000 2013-02-09 00:00:00.000 sick    NULL
Bala    82  16  2013-02-07 00:00:00.000 2013-02-09 00:00:00.000 sick    NULL


executed more than once whta can i do.
Posted
Updated 30-Jan-13 0:15am
v3

Check your join. You have one more common column between tables apart from empid and authorityid.Find it and add it to the where clause
 
Share this answer
 
Comments
CHill60 30-Jan-13 6:26am    
Or better yet - use JOIN ... ON to explicitly indicate which parts of the WHERE are just to join the tables
are you sure you do not have duplicate data? Also try to give schema of tables and FK relationship.
If you have duplicate data, you can use DISTINCT to get only distinct value.

http://www.w3schools.com/sql/sql_distinct.asp[^]
 
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