Solved

SQL database

Posted on 2013-01-10
3
375 Views
Last Modified: 2013-01-10
I need to know how to select the  first time, Second time and Third time PO approval employee name. when I tred as below , but output  show EmployeeID  only.

Can you please help ……….. please see attached image

SELECT     tbl_PoAproval.FistAproval, tbl_PoAproval.FistAprovalDate, tbl_PoAproval.SecondAproval, tbl_PoAproval.SecondAprovalDate, tbl_PoAproval.ThirdAprovalDate,

                      tbl_PoAproval.ThirdAproval, tbl_PoAproval.PONumber, Employees.FirstName

FROM         tbl_PoAproval INNER JOIN

                      Employees ON tbl_PoAproval.FistAproval = Employees.EmployeeID

WHERE     (tbl_PoAproval.PONumber = 'WA-011075')
image001.png
0
Comment
Question by:upalakshitha
3 Comments
 
LVL 1

Accepted Solution

by:
tissier earned 250 total points
ID: 38762203
Hi,

I didn't check, but try this :
SELECT     tbl_PoAproval.FistAproval, tbl_PoAproval.FistAprovalDate, tbl_PoAproval.SecondAproval, tbl_PoAproval.SecondAprovalDate, tbl_PoAproval.ThirdAprovalDate,
tbl_PoAproval.ThirdAproval, tbl_PoAproval.PONumber, 
FirstApprovalEmployee.FirstName,
SecondApprovalEmployee.FirstName,
ThirdApprovalEmployee.FirstName

FROM         tbl_PoAproval INNER JOIN
    Employees as FirstApprovalEmployee ON tbl_PoAproval.FistAproval = FirstApprovalEmployee.EmployeeID
INNER JOIN
    Employees as SecondApprovalEmployee ON tbl_PoAproval.SecondAproval = SecondApprovalEmployee.EmployeeID
INNER JOIN
    Employees as ThirdApprovalEmployee ON tbl_PoAproval.ThirdAproval = ThirdApprovalEmployee.EmployeeID

WHERE     (tbl_PoAproval.PONumber = 'WA-011075')

Open in new window

0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 250 total points
ID: 38762251
correct

YOu need to join the same table again 3 times , Just changing naming convetions to better understand

SELECT     tbl_PoAproval.FistAproval, tbl_PoAproval.FistAprovalDate, tbl_PoAproval.SecondAproval, tbl_PoAproval.SecondAprovalDate, tbl_PoAproval.ThirdAprovalDate,
tbl_PoAproval.ThirdAproval, tbl_PoAproval.PONumber,
FirstApprovalEmployee.FirstName as First_Approver,
SecondApprovalEmployee.FirstName as Second_approvar,
ThirdApprovalEmployee.FirstName as Third_approvar

FROM         tbl_PoAproval INNER JOIN
    Employees as FirstApprovalEmployee ON tbl_PoAproval.FistAproval = FirstApprovalEmployee.EmployeeID
INNER JOIN
    Employees as SecondApprovalEmployee ON tbl_PoAproval.SecondAproval = SecondApprovalEmployee.EmployeeID
INNER JOIN
    Employees as ThirdApprovalEmployee ON tbl_PoAproval.ThirdAproval = ThirdApprovalEmployee.EmployeeID

WHERE     (tbl_PoAproval.PONumber = 'WA-011075')
0
 
LVL 13

Author Closing Comment

by:upalakshitha
ID: 38762378
Thank you...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question