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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:08:40+00:00 2026-06-03T05:08:40+00:00

Short My tables structure looks like that And here is Sql statements $stmt =

  • 0

Short

My tables structure looks like that

enter image description here

And here is Sql statements

            $stmt = $this->db->prepare("DELETE FROM chapters WHERE (subject_id=? AND id = ?)") or die($this->db->error());
            $stmt->bind_param("ii", $subject_id, $node);
            $stmt->execute();
            $stmt = $this->db->prepare("DELETE FROM sections WHERE (subject_id=? AND chapter_id=? )") or die($this->db->error());
            $stmt->bind_param("ii", $subject_id, $node);
            $stmt->execute();
            $stmt = $this->db->prepare("DELETE FROM paragraphs WHERE (subject_id=? AND chapter_id=?)") or die($this->db->error());
            $stmt->bind_param("ii", $subject_id, $node);
            $stmt->execute();

So what I want to do is, to merge this 3 statements into one and optimize server load.

Detailed

For ex., if I want to delete row with id=1 from chapters table, then also delete from 2 more tables: sections, paragraphsby 2 parameters: $node and $subject_id (Of course, If there is rows with those parameters. I mean there must be join to prevent any error).

Question is..

Is that possible? I can’t figure out, how sql statement must look like. Any suggestions?

  • 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-03T05:08:41+00:00Added an answer on June 3, 2026 at 5:08 am

    If you have set up foreign key constraints with ON DELETE CASCADE then you only need to delete the parent row. MySQL will then delete the child rows automatically.

    • How do I use on delete cascade in mysql?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few tables in SQL that are pretty much like this A
I inherited an interesting table structure. This table structure looks like the following: GroupTable
This question is about a general technique in SQL, that I can't quite work
I have a structure that looks following Class TreeNode { public TreeNode Parent {
Short version: How can I map two columns from table A and B if
Im trying to eliminate two tables from my database. The tables are message_sort_options and
I want to create a database structure that will has good efficiency. Now database
I'm trying to crate a data structure sort of like a dictionary in Python,
I have 2 tables with the following structure.. category { sub_cat_id - numeric sub_cat_name
Short version: is it safe to use ets:foldl to delete every ETS record as

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.