Hi All,

What Wrong with my QUERY ! it show Repetition of Record in INNER Join i.e when i have 3 record in database it show it 9 time using This query....

SELECT     
    dbo.EmployeeSetup.EmpID, dbo.EmployeeSetup.EmpName, dbo.EmployeeSetup.FatherName, dbo.EmployeePayment.Designation,
    dbo.EmployeePayment.Department, dbo.EmployeePayment.Salary, dbo.EmployeePayment.Advance, dbo.EmployeePayment.Deduction,
    dbo.EmployeePayment.OvertimeAmount, dbo.EmployeePayment.PaymentDate, dbo.EmployeePayment.ModeOfPayment,
    dbo.EmployeePayment.NetPay, dbo.EmployeePayment.PayMonth, dbo.EmployeePayment.Fine, dbo.EmployeePayment.Fund,
    dbo.EmployeePayment.Insurence, dbo.EmployeePayment.Tax, dbo.tblAllownce.MedicalAllownce, dbo.tblAllownce.DailyAllownce,
    dbo.tblAllownce.TravellingAllownce, dbo.tblAllownce.OtherAllownce, dbo.EmployeeSetup.Salary AS BasicSalary,
    dbo.EmployeeSetup.JoiningDate, dbo.EmployeePayment.PayDateFor
FROM         
    dbo.EmployeePayment 
INNER JOIN
    dbo.EmployeeSetup 
    ON dbo.EmployeeSetup.EmpID = dbo.EmployeePayment.EmpID 
INNER JOIN
    dbo.tblAllownce 
    ON dbo.EmployeeSetup.EmpID = dbo.tblAllownce.EmpID

Recommended Answers

All 10 Replies

Member Avatar for diafol
 ON dbo.EmployeeSetup.EmpID = dbo.EmployeePayment.EmpID 

Don't know if it will make a diff

 ON dbo.EmployeePayment.EmpID  = dbo.EmployeeSetup.EmpID 

Sir !
It show Same Result

Can you provide some sample data? A bit difficult with just seeing the query.

Photo

Query

select * from tblAllownce

1 2013-06-29 Fend-IT-001 Khair Ullah Software Developer IT 0 0 0 0 0 June-2013
2 2013-06-29 Fend-IT-001 Khair Ullah Software Developer IT 0 0 0 0 0 May-2013

select * from EmployeeSetup

3 Fend-HR-003 001-IT Ahmad Abid Male BS(CS) 6 Months Accountant Dir -6533329 1992-02-01 234344443 tufail@yahoo.com Dir Pakistani Islam uiyuyuu Married erererr 2013-06-25 08:00:00 34565.00
1 Fend-IT-001 001-IT Khair Ullah Rehan Male BS(CS) 1 Year Software Developer Peshawar -4195-599 - 1989-03-01 3469184015 khairullah_swat@yahoo.com Swat Pakistani ISLAM Swat Unmarried Pashtu 2013-02-15 08:00:00 13000.00
2 Fend-IT-002 001-HR Tufail Ahmad Zaman Male BS(CS) Less Then 6 Months S W Dev Dir -1698385 1990-01-01 3139020637 tufailahmad29@yahoo.com Dir Lower Pakistani Islam Dir Married Pushto 2012-02-01 08:00:00 100000.00

select * from tblAllownce

1 2013-06-29 Fend-IT-001 Khair Ullah Software Developer IT 0 0 0 0 0 June-2013
2 2013-06-29 Fend-IT-001 Khair Ullah Software Developer IT 0 0 0 0 0 May-2013

Which one is the EmpID ?

Fend-IT-001

Fend-HR-003

Member Avatar for diafol

Are you running this via phpMyAdmin or via php?

Try it in phpMyAdmin to see how many records you get. You say you only have 3 in the first table?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.