Link to home
Start Free TrialLog in
Avatar of josephrrc
josephrrc

asked on

Ref-Ontana request for code(Unable to get Ontanas EMAIL)

SELECT Sal_Mas.Emp_No, Sal_Mas.Emp_SurName, transfile.tran_empno, transfile.SalaryAdv, Sal_Mas.Emp_Basicsal, Sal_Mas.Allow1, Sal_Mas.Allow2, Sal_Mas.Allow3, Sal_Mas.Allow4, Sal_Mas.Allow5, Sal_Mas.Allow6, Sal_Mas.Allow7, Sal_Mas.Allow8, Sal_Mas.InterimAllow, transfile.Festadv, transfile.Lunch, transfile.StaffPfContr, transfile.Loan, transfile.CollegePFLoan, transfile.Paye, transfile.SundryDed,


FROM Sal_Mas, transfile WHERE
 Sal_Mas.Emp_No = transfile.tran_empno

UNABLE TO GET ALL TRANSACTIONS FROM MASTERFILE PLS HELP ME WITH THE CODE

MASTER FILE IS sal_mas
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

You need a LEFT JOIN:

SELECT Sal_Mas.Emp_No, Sal_Mas.Emp_SurName, transfile.tran_empno, transfile.SalaryAdv, Sal_Mas.Emp_Basicsal,
Sal_Mas.Allow1, Sal_Mas.Allow2, Sal_Mas.Allow3, Sal_Mas.Allow4, Sal_Mas.Allow5, Sal_Mas.Allow6, Sal_Mas.Allow7,
Sal_Mas.Allow8, Sal_Mas.InterimAllow, transfile.Festadv, transfile.Lunch, transfile.StaffPfContr, transfile.Loan,
transfile.CollegePFLoan, transfile.Paye, transfile.SundryDed


FROM Sal_Mas
LEFT OUTER JOIN transfile
ON Sal_Mas.Emp_No = transfile.tran_empno
ASKER CERTIFIED SOLUTION
Avatar of alaplume
alaplume

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of loveneesh_bansal
loveneesh_bansal

Hi the answer is so simple you have done every thing right but if you go once agin from your query you will find that in the select statement (before the where clause) you didnot mention the "transfile.tran_empno" field.

The right query shoul be like


SELECT Sal_Mas.Emp_No, Sal_Mas.Emp_SurName, transfile.tran_empno, transfile.SalaryAdv, Sal_Mas.Emp_Basicsal,
Sal_Mas.Allow1, Sal_Mas.Allow2, Sal_Mas.Allow3, Sal_Mas.Allow4, Sal_Mas.Allow5, Sal_Mas.Allow6, Sal_Mas.Allow7,
Sal_Mas.Allow8, Sal_Mas.InterimAllow,transfile.tran_empno, transfile.Festadv, transfile.Lunch, transfile.StaffPfContr, transfile.Loan,
transfile.CollegePFLoan, transfile.Paye, transfile.SundryDed,


FROM Sal_Mas, transfile WHERE
Sal_Mas.Emp_No = transfile.tran_empno


i know now the program will definately work.


Bye
Loveneesh

actually, the transfile.tran_empno field WAS already in the query.

Not that it matters if it wasn't, because it's perfectly possible to put a field in the WHERE clause which you have not selected.

But on the topic: Emoreau is right. With a left join you get all records in the first table, linked to their corresponding fields in the other table or a NULL-record where there are no corresponding records.

Hope it helped, :)
Avatar of josephrrc

ASKER

Thanks to all u nice guys my payroll prg is now working fine.Thanks alot may be any more problems I shall come back again to all u computer wizards
Cheers,
Josephrrc
Thanks to all u nice guys my payroll prg is now working fine.Thanks alot may be any more problems I shall come back again to all u computer wizards
Cheers,
Josephrrc
You need to accept one of the comment now!
Now the prg is working thanks lot
cheers