Advertisement

04.21.2003 at 10:13AM PDT, ID: 20591435
[x]
Attachment Details

SQL Query-need to use 1 field to pull info from 2 other fields based on info in 2 fields in another table

Asked by BHaines in Active Server Pages (ASP)

Tags: field, sql, another, based, 1

Ok, I've wracked my brain for weeks and I can't seem to get this to work. I have 2 tables, the first we'll call Research, the second Employees. In Research table there are 2 fields, CreatedBy and AssignedTo, which both contain int values corresponding to an EmployeeID in the Employees table. The Employees Table has the EmployeeID, FirstName, and LastName fields which correspond to each ID. For the page I'm creating the CreatedBy needs to be translated to the person's First and Last Name and have that displayed, while the AssignedTo needs to be displayed in the same way for each record in the Research Database. Example:

Research Table
ID CreatedBy AssignedTo
1..1112......2221
2..1113......3332
3..1112......<NULL>

Employees Table
EmployeeID  FirstName  LastName
1112........Bob........Smith
1113........Jane.......Doe
2221........Peter......Cottontail
3332........Snow.......White

The page needs to display
ID....CreatedBy....AssignedTo
1.....Bob Smith....Peter Cottontail
2.....JaneDoe......Snow White
3.....Bob Smith....Unassigned

I'm having a beast of a time getting this to work. I can get it to show Unassigned if the field value is null. I can get CreatedBy OR AssignedTo to show up properly, but not both. How can I get the info in the Employees table to show up based on the value in CreatedBy, then adjust itself to show up based on the value in AssignedTo? Any help would be appreciated.Start Free Trial
[+][-]04.21.2003 at 10:19AM PDT, ID: 8367776

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2003 at 10:21AM PDT, ID: 8367784

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2003 at 10:26AM PDT, ID: 8367805

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2003 at 10:27AM PDT, ID: 8367816

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Active Server Pages (ASP)
Tags: field, sql, another, based, 1
Sign Up Now!
Solution Provided By: thomasdodds
Participating Experts: 2
Solution Grade: A
 
 
[+][-]04.21.2003 at 12:57PM PDT, ID: 8368851

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2003 at 01:03PM PDT, ID: 8368895

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2003 at 01:03PM PDT, ID: 8368897

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2003 at 01:07PM PDT, ID: 8368924

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2003 at 01:07PM PDT, ID: 8368925

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2003 at 01:08PM PDT, ID: 8368938

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32