Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7686187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:25:22+00:00 2026-05-31T19:25:22+00:00

I’m building a blog engine in C# Webforms and I have the following code

  • 0

I’m building a blog engine in C# Webforms and I have the following code that selects all blog posts that are current, meaning they should be displayed and a count of all comments for each blog post and it works great.

SELECT PostID, PostTitle, PostDate, PostTeaser, Count(CommentID) AS CountOfCommentID, PostCurrent 
FROM TBLBlogPost 
    INNER JOIN TBLBlogComment ON PostID = PostCommentFK 
GROUP BY PostID, PostTitle, PostDate, PostTeaser, PostCurrent
HAVING PostCurrent = 'True'

The problem is it only selects blog posts that have at least one comment.

Does anyone know how I can fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:25:23+00:00Added an answer on May 31, 2026 at 7:25 pm

    You should use a LEFT JOIN then, instead of the INNER JOIN

    SELECT PostID, PostTitle, PostDate, PostTeaser, Count(CommentID) AS CountOfCommentID, PostCurrent 
    FROM TBLBlogPost 
        LEFT JOIN TBLBlogComment ON PostID = PostCommentFK 
    GROUP BY PostID, PostTitle, PostDate, PostTeaser, PostCurrent
    HAVING PostCurrent = 'True'
    

    INNER JOIN means that the matching table MUST match or else it will not fill the resultset. A LEFT JOIN means that if the match is not made, it will fill everything from that table with NULL

    Here is a good visual representation of the different SQL joins.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an authors page for my Wordpress blog that lists all the current
I'm building a blog that should parse bbcode tags like this: Input: <youtube=http://www.youtube.com/watch?v=VIDEO_ID&feature=channel> Output:
Right now I'm building a personal site/blog and have pretty much got it they
Here I have pasted link for code: http://blog.asolutions.com/2010/09/building-custom-map-annotation-callouts-part-1/ In this code I have just
I'm building a blog using RoR. I have the index.html.erb page for the posts
So I'm building a blog engine which has /articles/then-the-article-permalink as it's URL structure. I
Hey guys. I'm building a simple blog and have my data returning from my
I'm building off the CakePHP tutorial for the blog engine by adding comments to
I am building a group blog that is moderated by the community. When a
I'm building a lifestream-esque sort of blog in PHP. It fetches my blog posts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.