Help with query...

A

Andrew Meador

I need to create a querry that needs to have values of two
different columns to be looked up in another table. Ex.

Table: ChangeDetails
Column: Note
Column: PaperStatusID
Column: DigitalStatusID

Table: Status
Column: StatusID
Column: Description

I need a querry that will display the Note, Description from the
Status table (where PaperStatusID = StatusID), and Description from
the Status table (where DigialStatusID = StatusID).

I need this in a single query, but I'm not good at queries yet and
can't figure out how to do this.

Here is sample data to clarify what I need:

Table: ChangeDetails
Note: Parcel Drawn PaperStatusID: 3 DigitalStatusID: 2
Note: Dwelling mark removed PaperStatusID: 2 DigitalStatusID: 1
Note: Dwelling mark added PaperStatusID: 1 DigitalStatusID: 1

Table: Status
StatusID: 1 Description: Done
StatusID: 2 Description: Not Done
StatusID: 3 Description: Needs Research

Querry Result:
Parcel Drawn, Needs Research, Not Done
Dwelling mark removed, Not Done, Done
Dwelling mark added, Done, Done

Thanks in advance!
 
W

Wolfgang Kais

Hello Andrew.

Andrew said:
I need to create a querry that needs to have values of two
different columns to be looked up in another table. Ex.

Table: ChangeDetails
Column: Note
Column: PaperStatusID
Column: DigitalStatusID

Table: Status
Column: StatusID
Column: Description

I need a querry that will display the Note, Description from the
Status table (where PaperStatusID = StatusID), and Description from
the Status table (where DigialStatusID = StatusID).

I need this in a single query, but I'm not good at queries yet and
can't figure out how to do this.

Here is sample data to clarify what I need:

Table: ChangeDetails
Note: Parcel Drawn PaperStatusID: 3 DigitalStatusID: 2
Note: Dwelling mark removed PaperStatusID: 2 DigitalStatusID: 1
Note: Dwelling mark added PaperStatusID: 1 DigitalStatusID: 1

Table: Status
StatusID: 1 Description: Done
StatusID: 2 Description: Not Done
StatusID: 3 Description: Needs Research

Querry Result:
Parcel Drawn, Needs Research, Not Done
Dwelling mark removed, Not Done, Done
Dwelling mark added, Done, Done

Thanks in advance!

SELECT ChangeDetails.Note, Paper.Description AS PaperStatus,
Digital.Description AS DigitalStatus FROM (ChangeDetails
INNER JOIN Status AS Paper
ON ChangeDetails.PaperStatusID = Paper.StatusID)
INNER JOIN Status AS Digital
ON ChangeDetails.DigitalStatusID = Digital.StatusID;
 
A

Andrew Meador

Thank you Wolfgang - that was it! I knew it couln't be too hard, I
just haven't gotten a good handle on how to deal with joins yet. I
appreciate it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top