0

I want to make a SQL query that will link data from two tables, and then relate the data from the second table like this

SELECT CustNo AS 'Customer No.', CompanyName, LiasonNo AS 'Liason'  
FROM Customer

What I want to do, is relate Liason Number to the Employee Number on another table and then have it list that number as the Employee LastName.

Would I use an inner join to do this?

1 Answer 1

3
SELECT  a.CustNo as 'Customer No',
        a.CompanyName,
        b.LastName
FROm    Customer a
        INNER JOIN table2 b 
            ON a.LiasonNo = b.EmployeeNo
Sign up to request clarification or add additional context in comments.

9 Comments

Yeah, I got that far, but how would I make the query show EmployeeNo as the Employee.LastName ?
the query above show the lastname of the employee, can you explain your question more?
SELECT CustNo ', CompanyName ,Customer.LiasonNo AS 'Liason' FROM Customer INNER JOIN Employee ON Customer.LiasonNo = Employee.EmpNo AND Employee.EmpNo = Employee.LastName
Doing this, I get the conversion to smallint error. The only data linking the two tables is the LisasonNo = Employee.EmpNo so from EmpNo, I need it to display the actual last name of the Employee on the employee table.
Using SELECT Employee.Lastname and then Innerjoin the LiasonNo = EmpNo Thanks!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.