Combining different tables

Rando

New member
Local time
Today, 03:05
Joined
Sep 22, 2010
Messages
8
Hi everyone,

I've ran into an issue I've not had to deal with before. I have two tables, both are similar, but one table has a few more columns than the other one. I'd like to have a single query for both tables that displays combined results including all the columns from both tables. I know a Union Select is probably my best bet, but I'm not sure how to go about it. My table information is below, I'm just looking for a Select * in general

The columns in bold exist in table 1 but not table 2.

Table 1
EmpID
Login
Name
HourlyRate
LeadName
ManagerName
ManagerIIName
DirectorName
EffectiveDate

Table 2
EmpID
Login
Name
ManagerIIName
DirectorName
EffectiveDate
 
Hi,
you are right you would use a union select query, as the tables do not have the same fields, we can make the changes to view inthe query.
table 1 has all the fields so you would show everything from that.
you would add thr missing fields in table 2, giving you identical tables making the union work. try something like this:

select * from [Table 1]
union select *, '' as HourlyRate, '' as LeadName, '' as ManagerName from [Table 2]


Note: the '' are 2 aphostaphe's not a single quotation.
 

Users who are viewing this thread

Back
Top Bottom