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 8819679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:25:18+00:00 2026-06-14T05:25:18+00:00

Sorry for the ridiculous question title. I didn’t know how to generalize it. I

  • 0

Sorry for the ridiculous question title. I didn’t know how to generalize it.

I need a list of comments that occur after my comments left on a post I did not create.

I’m using postgres. My post table structure:

CREATE TABLE posts (
    id integer NOT NULL,
    parent_id integer DEFAULT (-1),
    msg character varying(140),
    user_id integer,
    create_dte numeric(10,0) DEFAULT 0
);

There can only be one level of comments. Original posts
have a parent_id of -1. Comments have a parent_id of an original post’s id.

I can get my comments on posts I didn’t create:

select p1.id, p1.msg 
from   posts p1 
where  p1.user_id = MY_USER_ID 
and    p1.parent_id in (
    select p2.id 
    from   posts p2 
    where  p2.parent_id = -1 
    and    p2.user_id != MY_USER_ID)

Can someone give me a hint on how to select the posts that have the same parent_id
and a greater create_dte?

  • 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-06-14T05:25:20+00:00Added an answer on June 14, 2026 at 5:25 am

    I used the answer from @podiluska above as a jumping-off point for this solution:

    select
        posts.*
    from
        posts
            inner join
            (
                (
                    select h1.parent_id, min(h1.create_dte_timestamp) as min_date
                    from posts h1
                    where
                        h1.parent_id != -1 and
                        h1.user_id = USER_ID and
                        h1.parent_id not in
                        (
                            select h2.id
                            from posts h2
                            where h2.id = h1.parent_id and h2.user_id = USER_ID
                        )
                        group by h1.parent_id
                )
            ) lastpost
            on posts.parent_id = lastpost.parent_id
    
    where
        posts.create_dte_timestamp > lastpost.min_date and
        posts.user_id != USER_ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for the vague title, I didn't know how else to phrase this. Suppose
(Sorry I know the question sounds ridiculous) and if so which of the following
Sorry, I know this question is easy, but I don't know how to get
Sorry for the bad title - I simply do not know what to call
Sorry for such a basic question. After using MS Visual Studio for 15 years,
Sorry the title isn't more help. I have a database of media-file URLs that
Sorry if this sounds like a really stupid question, but I need to make
Sorry for the long question title. I guess I'm on to a loser on
Sorry this is going to sound like a ridiculous question but can methods (not
I'm sorry if this is a ridiculous question but I'm just learning python and

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.