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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:11:19+00:00 2026-05-26T23:11:19+00:00

A related example: table activity activity id | title 1 a 2 a2 3

  • 0

A related example:

table activity
activity id | title
1             a
2             a2
3             b
4             b2

table people
id | parent id | activity id | active

Grab all the people who:

  • is in a specific activity without a parent
  • is in a specific activity who’s parent is not in the same activity + not in the same related activity (ie: a, a2)

So far I have something less than ideal:

SELECT p.pid FROM people p
left join activity a
on p.activityid = a.activityid
where p.active = 1
and a.title = 'a'
and EXISTS (
    SELECT p1.pid from people p1
    left join activity a1
    on p1.activityid = a1.activityid
    where p.parentid = p1.id
    and a1.activityid != p.activityid
    or p.parentid = 0
)

This doesn’t account for parentids not ‘a2’ or ‘b2’ etc..
The thing is I have the target activity id I want, but not the related activity, so I figured I’d somehow use the title instead?

  • 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-26T23:11:20+00:00Added an answer on May 26, 2026 at 11:11 pm

    You don’t need a outer join. The not exixts clause will filer out someone without parents.

    SELECT p.pid 
    FROM people p,  activity a 
    WHERE p.activityid = a.activityid 
    AND p.active = 1 AND a.title = 'a' 
    AND NOT EXISTS
    ( SELECT 1 FROM people pp, activity pa
      WHERE p.parentid = pp.id AND pp.activityid = pa.activityid
      AND pa.title NOT LIKE a.title||'%'
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example i have a Contact table that is related to Addresses. To communicate
I have to related tables like in the example script below: -- Creating table
For example i'm doing inner join on the same table. I want to pick
This is somewhat asp.net MVC related only for example purposes but I was hoping
In this example, <%=button_to_remote Get Related Users, {:url => { :action => 'get_related_users' },
I have a simple question related to one-line programming. First an example: function test(a)
Last week i read about liquibase quick start and all the related tutorials but
Related Using SO as an example, what is the most sensible way to manage
how can I access any table from database in my model? For example, I
I have a page that, when accessed displays a table of information related to

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.