Reputation: 27285
I have two tables in my SQL Server database:
Person
ID Lastname Age
1 Jones 46
2 Smith 37
Employee
ID(FK) Firstname Surname
1 Bob [empty string]
2 Janet [empty string]
I want to combine Employee as follows. (I will then be removing the Lastname from person, but let's not worry about that for now.)
Employee
ID (FK) Firstname Surname
1 Bob Jones
2 Janet Smith
How can I do that?
Upvotes: 2
Views: 142
Reputation: 1499
Select E.ID, E.Firstname, P.Lastname as Surname from Employee E
inner join Person P on P.ID=E.ID
Upvotes: 2
Reputation: 3706
I Think you should try this query, by this way you will have your desired result based on both tables.
Select E.ID, E.FirstName P.Lastname As Surname From Person P
Inner join Employee E ON p.ID = E.ID
Upvotes: 2