Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Newbie needs help!

Author  Topic 

jonahpup
Starting Member

4 Posts

Posted - 2007-09-13 : 19:05:18
Hi there.

I am wanting to display some fields from 5 different tables.

Here is a database diagram to show how the tables are linked.



Basically what I want to show is:

LastName, FirstName (ConsultantName), Action
when CaseStatus is anything other than "Declined" or "Invalid"


If anyone could help me that would be great...
Cheers
Chris

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-13 : 19:10:41
SELECT at.LastName, at.FirstName, ct.ConsultantName, art.Action
FROM ApplicationTable AS at
INNER JOIN ActionRequestTable AS art ON art.ApplicationUID = at.ApplicationUID
INNER JOIN ApplicantTable AS at ON at.UID = at.ApplicantUID
INNER JOIN ConsultantTable AS ct ON ct.UID = at.ConsultantUID
INNER JOIN CaseStatusTable AS cst ON cst.UID = at.CaseStatusUID
WHERE cst.CaseStatus NOT IN ('Declined', 'Invalid')



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2007-09-13 : 19:13:47
Is this for a school project?

Select C.LastName, C.FirstName, B.Action
from
ApplicationTable A
LEFT JOIN ActionRequestTable B ON A.Uid = B.ApplicationUid
LEFT JOIN ApplicantTable C ON A.ApplicantUid = C.Uid
LEFT JOIN ConsultantTable D ON A.ConsultantUid = D.Uid
LEFT JOIN CaseStatusTable E ON A.CaseStatusUid = E.Uid
Where E.CaseStatus not in ('Declined','Invalid')

alternatively

WHERE E.CaseStatus <> 'Declined' and E.CaseStatus <> 'Invalid'

PS: If anyone is interested in a SQL Server position in Connecticut with excellent pay send me your resume to ValterBorges@msn.com
Go to Top of Page
   

- Advertisement -