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.
| Author |
Topic |
|
HockeyFan
Starting Member
26 Posts |
Posted - 2006-03-05 : 13:09:45
|
| I don't do SQL on a regular basis and don't really know much about JOINs. Can someone help me form a proper SQL statement to achieve what I need.I have to do a search on any or all of:Lastname, firstname, active , contacttype, organizationI know there will be multiple sql statements, but I figured if I could get one, I could figure out the rest.Table A.Firstname, Lastname, ContactID, ActiveIndicatorTable B.ID, ContactID, ContactTypeIDTable C.ContactTypeID, DescriptionTable D.ContactID, OrgIDTable E.OrgID, OrgNameSo in my first search, what if I have the ContactID from Table A. Now what?In this case, I know the contact is Active because I have that in Table A. However, I don't have ContactType, or the Organization name. I guess it's possible that there could be more than one. |
|
|
shallu1_gupta
Constraint Violating Yak Guru
394 Posts |
Posted - 2006-03-06 : 00:06:19
|
| Try this..Select A.Firstname, A.Lastname , A.activeIndicator, B.contacttype, E.orgname as organizationfrom TableA Ainner join TableB Bon A.ContactId = .ContactIdinner join TableC COn B.ContactId = C.ContactIdinner join TABLED Don C.ContactId = D.ContactIdinner join TABLEE Eon D.ORGID = E.ORGIDwhere A.contactID = <?> |
 |
|
|
|
|
|
|
|