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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:12:41+00:00 2026-06-07T21:12:41+00:00

Looking for query, remove all record of child table where parent id not match

  • 0

Looking for query, remove all record of child table where parent id not match with master record.

Master-Table

 1. David
 2. Fin
 3. Lisa

Child-Table

 1. 100
 1. 200
 2. 200
 2. 222
 8. 100
 9. 100

Output Required on Child Table

 1. 100
 1. 200
 2. 200
 2. 222

want to remove record # 8 and 9 from child table, cuz it doesn’t have parent id.

Thanks

  • 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-07T21:12:44+00:00Added an answer on June 7, 2026 at 9:12 pm

    You can use an outer join in a DELETE operation:

    DELETE a 
    FROM child a
    LEFT JOIN master b ON a.parent_id = b.id
    WHERE b.id IS NULL
    

    To prevent the need to do this, what you should look into are Referential CASCADE actions that execute whenever you delete a parent (row in the master table).

    If you have an ON DELETE CASCADE set up on the foreign key in your child table, any parent that gets deleted will also have all of its corresponding “children” deleted as well.

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

Sidebar

Related Questions

I'm looking to query all databases mapped to a user, similar to Security >
I am looking at the query syntax . and i could not figure out
Looking to have a database query set all the instance variables in a class:
Im looking to run a query on my external database, i got all the
I am looking to remove an element from an ArrayList using a query, E.g.
Am looking for a query to sum values in a particular time duration say
I'm looking for a query that takes mostly consecutive days and groups them together
Looking for some help with optimising the query below. Seems to be two bottlenecks
I'm looking for a way to query the linux man pages through an API,
I'm looking for a way to query a state in a state machine 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.