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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:32:15+00:00 2026-06-01T02:32:15+00:00

I have a MySQL database set-up in a hierarchy style. There are 4 tables

  • 0

I have a MySQL database set-up in a hierarchy style. There are 4 tables called pages, regions, elements, and content. Pages is at the top, and content is at the bottom.

To simplify:

pages has the column:

id

regions has the columns:

id
page_id

elements has the columns:

id
region_id

content has the columns:

id
element_id

I want to be able to delete all the children of pages using just the page’s id.

So far, I’ve been able to use a nested select statement to select the bottom content using the page’s id, but that doesn’t select the elements, regions, or the page.

SELECT * FROM `content` WHERE `element_id` IN (
    SELECT `id` FROM `elements` WHERE `region_id` IN (
        SELECT `id` FROM `regions` WHERE `page_id` IN (
            SELECT `id` FROM `pages` WHERE `id` = 1
        )
    )
) 

Anyway to do this efficiently? Thanks.


Thanks to @Hago and @Churk, here’s my final solution (basically Churk’s code, a tiny bit modified):

DELETE `content`, `elements`, `regions` FROM `content`
JOIN `elements` ON `elements`.`id` = `content`.`element_id`
JOIN `regions` ON `regions`.`id` = `elements`.`region_id` 
JOIN `pages` ON `pages`.`id` = `regions`.`page_id`
WHERE `pages`.`id` = 1
  • 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-01T02:32:17+00:00Added an answer on June 1, 2026 at 2:32 am
    DELETE FROM content
    JOIN elements ON elements.id = content.element_id
    JOIN regions ON regions.id = elements.region_id 
    JOIN pages ON pages.id = regions.page_id
    WHERE pages.id = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, so I have a MySQL database set up. Most of the tables are
I have a mysql database which have set of tables One table have a
I have a mysql database set as utf-8, and csv data set as utf-8,
I have a mysql database which has grown to over 200 tables in it.
i have a simple mysql database. it has 3 tables. here is the create
I have a MySQL database with tables for Items and for Stores , and
I have set my MySQL database to utf8 and my table and column as
So I have a MySQL database set up on a Debian server and it
I have a MySQL database that contains many tables, some of them created dynamically
I have a MySQL database set up on 000webhost.com. I want to access the

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.