Following is a simplified version of something I'm struggling with at the moment. Let's say I have the following two tables. tblMain has some information, and its Primary key is "id". tblComments has a field called recid which matches tblMain.id. In this sample, Tom has 3 comments, Pete has 1, and Joe has none.
I would like to create a query that returns all the records in tblMain, plus a column that contains "Yes" or "No" depending on whether that record has any "comment" records in tblComments, like this:
Can someone help with the nested select needed?
Code:
[b]tblMain:[/b]
id Name
=============
1 Tom
2 Joe
3 Pete
[b]tblComments:[/b]
id recid CommentText
===============================
1 1 Tom's first comment
2 1 Tom's second comment
3 1 Tom's third comment
4 3 Pete's only comment
I would like to create a query that returns all the records in tblMain, plus a column that contains "Yes" or "No" depending on whether that record has any "comment" records in tblComments, like this:
Code:
id Name HasComments
===============================
1 Tom Yes
2 Joe No
3 Pete Yes