Link to home
Start Free TrialLog in
Avatar of Chris Miller
Chris MillerFlag for United States of America

asked on

Query Two Tables with the same Field name

I have a query with two tables, both tables have one field that has the same field name which is "TYPE". One table has "Full-time" and the other table has "Part-time". Both tables also have a field "Name Employee".

How do I define this in the query so that it looks at "Name Employee" and then based on the employee will show one column with either Full-time or Part-time.

Currently I have three columns, Name Employee, TYPE-Full-time & TYPE-Part-time.

I want only two columns, Name Employee & TYPE and in the single TYPE column it will either have Full-time or Part-time
Avatar of als315
als315
Flag of Russian Federation image

Do you have separate table with a list of all employees?
It will be better to have only one table, but in your case you can use union query.
SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Chris Miller

ASKER

I am not sure yet if I can combine some tables. Long story short is I am a 17 yr Sys Admin but I am new to databases. I have inherited a large Access 2007 DB and still figuring my way around it. I am looking to get it migrated into our Ent SQL but that my take some time.

peter57r: I will try that today to see if that works.

-Thanks
First comment is fine giving the main idea, second is a clarification and this one is a simplification.

SELECT tble1.* FROM tbl1
UNION ALL
SELECT tble2.* FROM tbl2;
hnasr,

I am getting this error.

Syntax error in FROM clause. (Error 3131)
peter57r,

I am getting this error.

Syntax error in FROM clause
You should have same table name. Now you have tble1.* and From tbl1.
If tables are tbl1 and tbl2, syntax will be:
SELECT tbl1.* FROM tbl1
UNION ALL
SELECT tbl2.* FROM tbl2;
But you should also ad¿ column with type if it is missing in your tables.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Got it working Thanks to Both of you!
Welcome!