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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:04:42+00:00 2026-05-24T22:04:42+00:00

I have 3 tables: AAA with the columns: id | text BBB with the

  • 0

I have 3 tables:

AAA with the columns:

id  |  text

BBB with the columns (aaa_id is a foreign key => id from the previous table – AAA):

id  |  text  | aaa_id

and CCC with the columns (bbb_id is a foreign key => id from the previous table – BBB):

id  |  text  | bbb_id

Now when I delete a record from the table AAA I want to delete all the records from the table BBB which are aaa_id = AAA.id and also delete all the records from the table CCC which are connected to the records I’d like to delete from BBB (so they have bbb_id equal to BBB.id of the records which are aaa_id equal to AAA.id).

I’ve tried to user inner join but I had no luck. Meanwhile, I select all the records with PHP and delete them separately.

The tables are MyISAM.

  • 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-24T22:04:44+00:00Added an answer on May 24, 2026 at 10:04 pm
    DELETE AAA, BBB, CCC
        FROM AAA
        LEFT JOIN BBB ON BBB.aaa_id = AAA.id
        LEFT JOIN CCC ON CCC.bbb_id = BBB.id
    

    You could use INNER JOIN as well, if there’s always child records in each table. Or you can set up ON DELETE CASCADE in your foreign key constraints.

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

Sidebar

Related Questions

I have the following: $columns = array('aaa','bbb','ccc','ddd'); $num_cols = count(columns); echo <table>; echo <tr>;
I have a table: ID Name -- ----- 1 aaa 2 bbb 2 ccc
I have a table with three columns: ColumnA ColumnB ColumnC AAA NULL 123 BBB
I have 2 simple tables: table a: id | txt ---+---- 0 | aaa
In my database I have tables that define types for example Table: Publication Types
I have two tables Product having following structure: ProductID,ProductName, IsSaleTypeA, IsSaleTypeB, IsSaleTypeC 1, AAA,
Excel Sheet data Eno EName Pincode 1 aaa 123456 2 bbb 123423 3 ccc
I have about 1 million rows on users table and have columns A AA
Hey there I have 2 tables with each multiple columns and i want to
I have an SQL Statement: SELECT * FROM users WHERE username = 'bbb' OR

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.