self-join query

  • Thread starter Thread starter al
  • Start date Start date
A

al

Greetings,

I have a problem trying to dislaly two columns from a table into a
combobox. The two columns are FirstName and LastName in Employees
table in Northwind db.

I have this select self-join query that I use through dataadapter
wizard:

SELECT
E1.EmployeeID,
E2.FirstName+' '+E2.LastName as reportsto,
E1. FirstName,
E1.Lastname,
E1.Title,
E1.TitleOfCourtesy,
E1.BirthDate,
E1.HireDate,
E1.Address,
E1.City,
E1.Region,
E1.PostalCode,
E1.Country,
E1.HomePhone,
E1.Extension,
E1.Notes,
E1.ReportsTo
FROM northwind..employees as E1
left outer join
northwind..Employees As E2 on E2.EmployeeID=E1.Reportsto

Select query works fine, but when I try to update the db, an error
message says, incorrect input format.
MTIA,
Grawsha
 
Hi al,

Your problem is that you can't that easily update two tables at once.
For selecting E2.FirstName+E2.LastName you'd rather use combobox bound to
E1.Reportsto field.
In that way you wouldn't need a join.
But if you are only display E2 fields, just remove them from
insert/update/delete commands.
 
Back
Top