Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to complex need help

Status
Not open for further replies.

nitrotech89

IS-IT--Management
Jan 30, 2013
5
US
Hi Have a table I'm importing from that has job codes these job codes need to be changed to the job description

I tried IIF Statement but I have 18 and Access can only handle 10

so I setup a second table with the the jobcode and descriptions

How do I take the imported table jobe code and refernce my second table to give me the description thanks

 
nitrotech89,
Welcome to Tek-Tips. You can create a query based on your imported table and your second table. Create a join by dragging the jobcode field from one to the other. You can then select all of the required fields into the query grid.

Duane
Hook'D on Access
MS Access MVP
 
Thanks

I was on the right track then I did add the second table.

How would this query look

First table is called Payroll Second table is Departments

I pull the Jobclass from the payroll file and it is called the number in the Departments table and what I would like is the to call is the dept in my departments table. this will give me my description to out put for my file thanks

 
Thanks

Sorry for not following that but not sure how it refeneces the to numbers to get me my description?

For Example when jobclass=number then it should display whats in the departments table dept field?

Does that make sense?

 
Sure thanks

First table is: Payroll
2nd Table is: Departments

The payroll table is the imported table, the field I'm looking at is jobclass
The second table has 2 fields number and Dept

the number is the same as jobClass

the dept is is the department description?

so when the import table comes in it will query jobclass and give me a number which is the same number as number in the Department table then it should give me the description which I will append to a diffrent table for an output file.

Hope this is clear thanks

 
Try something like this:[tt]

SELECT P.*, D.*
From Payroll P, Departments D
WHERE P.jobclass = D.[number]
ORDER BY ...
[/tt]

BTW - [tt]number[/tt] is a bad idea for a field name. It is a reserved word.

Have fun.

---- Andy
 
I typically use joins and the aliasing of the table names might be confusing.

SQL:
SELECT Payroll.*, Departments.*
From Payroll JOIN Departments ON Payroll.jobclass = Departments.[number]

Duane
Hook'D on Access
MS Access MVP
 
Ok I following your join there and I see how you are now getting the jobclass and number to equal
now how does it pull the description from that line so I can append it to my new table?

Thanks
 
If you try any of the examples you have been given, you will end up with all fields from both Payroll and Departments tables. One of the fields has to be 'description'


Have fun.

---- Andy
 
In relational databases, you don't want the description value stored anywhere other than the one table where it is currently residing. Use a query to display the description value with other tables.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top