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 |
|
obewankanoochie
Starting Member
24 Posts |
Posted - 2005-10-31 : 19:34:57
|
| Okay, I've got 3 tables. Subjects are the main table, and comments relate to subjects. However, some subjects won't have any comments to them. I'm stumped on how to get all the subjects even if they have comments. If they do have comments, I want those returned as well. Any help is greatly appreciated. Thanks.tblSubjects==========IdgroupIdmemberIdTitleSubjectDatatblComments===========commentIdsubjectIdmemberIdCommentDatamember===========memberIdmemberPhotoUrlSELECT s.Id, s.memberId, s.Title, s.SubjectData, m.memberPhotoUrl, c.memberId, c.CommentDataFROM tblSubjects s, tblComments c, member mWHERE s.groupId = #groupId#AND s.SubjectId = #Id#AND c.SubjectId = #Id#AND s.memberId = m.member_idAND c.memberId = m.member_idORDER BY s.Id ASC |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-10-31 : 19:40:54
|
read about joins in Books online = sql server help.USE them!!use left join for your problem.Go with the flow & have fun! Else fight the flow |
 |
|
|
|
|
|