Click here to Skip to main content
15,893,998 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii everyone,

in sql statement i need to add fildes from query that does not include in this form

SQL
SELECT tblPersonnel.EmpKey,tblPersonnel.amount_paid,tblPersonnel.amount_required,tblPersonne.amount_rest,tblPersonnel.Bus,tblPersonnel.Employee, tblPersonnel.LastName, tblPersonnel.FirstName, tblPersonnel.MiddleName, tblPersonnel.Shift, tblPersonnel.JobTitle, tblPersonnel.Department,tblPersonnel.HireDate, tblPersonnel.StartDate, tblPersonnel.BirthDate, tblPersonnel.Current, tblPersonnel.WorkStatus, tblPersonnel.Photo, tblAddresses.Address1,tblAddresses.Address2, tblAddresses.City, tblAddresses.State, tblAddresses.ZIP, tblAddresses.HomePhone, tblAddresses.WorkPhone, tblAddresses.CellPager, tblAddresses.EMail, tblNumber.SSN, tblEEOCData.Gender, tblEEOCData.Race, tblEEOCData.Veteran, tblEEOCData.Handicap FROM ((tblDepartments RIGHT JOIN ((tblPersonnel LEFT JOIN tblEEOCData ON tblPersonnel.EmpKey = tblEEOCData.EmpKey) LEFT JOIN tblNumber ON tblPersonnel.EmpKey = tblNumber.EmpKey) ON tblDepartments.DeptNo = tblPersonnel.Department) LEFT JOIN tblAddresses ON tblPersonnel.EmpKey = tblAddresses.EmpKey) LEFT JOIN tblPastEmployees ON tblPersonnel.EmpKey = tblPastEmployees.EmpKey;
Posted
Updated 6-Oct-12 20:28pm
v2
Comments
Sandip.Nascar 7-Oct-12 2:51am    
You question is very vague to give any reply. Please post more specific problem of your issue.
OriginalGriff 7-Oct-12 3:08am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.

1 solution

The above query can't works, because of wrong table name: tblPersonne.amount_rest - missed "l".

Try to use aliases[^], for example:
SQL
SELECT P.EmpKey, P.amount_paid, P.amount_required, P.amount_rest, P.Bus, P.Employee, P.LastName, P.FirstName, P.MiddleName,
    P.Shift, P.JobTitle, P.Department,P.HireDate, P.StartDate, P.BirthDate, P.Current, P.WorkStatus, P.Photo,
    A.Address1,A.Address2, A.City, A.State, A.ZIP, A.HomePhone, A.WorkPhone, A.CellPager, A.EMail, N.SSN,
    D.Gender, D.Race, D.Veteran, D.Handicap
FROM ((tblDepartments RIGHT JOIN ((tblPersonnel AS P LEFT JOIN tblEEOCData AS D ON P.EmpKey = D.EmpKey)
    LEFT JOIN tblNumber AS N ON P.EmpKey = N.EmpKey) ON tblDepartments.DeptNo = P.Department)
    LEFT JOIN tblAddresses AS A ON P.EmpKey = A.EmpKey)
    LEFT JOIN tblPastEmployees ON P.EmpKey = tblPastEmployees.EmpKey;


Finally i have a question: What's this for?
SQL
LEFT JOIN tblPastEmployees ON P.EmpKey = tblPastEmployees.EmpKey
 
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