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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:49:30+00:00 2026-06-11T04:49:30+00:00

i am having a mysql database, and in one table i have f_id as

  • 0

i am having a mysql database, and in one table i have f_id as P_Key and this f_id is referenced in multiple table as f_key. and i want to delete the records of this f_id(let say 10) from all the table in a once. then for this i need to delete in all the table which are having f_id= 10 as f_key then only i can delete this from the main table which contains it as a P_Key. can there be any automated process which can delete this by automatic looking into the table ,I dont want to write down the whole list of the table(as the list is very big more than 18 tables) in the query as this p_key is referenced in many tables.

  • 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-11T04:49:32+00:00Added an answer on June 11, 2026 at 4:49 am

    The easiest way to do this is set up an ON DELETE CASCADE CONSTRAINT on your keys such that on deletion of records on your parent table will delete all child records in your other tables that reference that row. Note that you’ll need to delete the foreign keys and and add them again if they don’t have an ON DELETE CASCADE constraint. Something like this:

    SHOW CREATE TABLE [table_name]
    
    ALTER TABLE [table_name] DROP FOREIGN KEY [f_id];
    
    ALTER TABLE [table_name]
    ADD CONSTRAINT [f_id]
    FOREIGN KEY (`[f_id]`) REFERENCES `[other_table]` (`[column_name]`)
    ON DELETE CASCADE;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having great problems solving this one: I have a mysql database encoding
I am using MySQL database. I have one table having column with datatype binary(16).
I have a mysql database table filled with 1000+ records, lets say 5000 records.
I have a mysql database table that will store locations for buildings and events
I have user table having fields gender and first name like this.. The value
MYSQL Database: I have a table of data that I need to put into
I am having issues with an InnoDB mysql database. E.g., I have two tables,
I am having problem with updating data to database. I have a simple many-to-one
Consider this: One mySQL database that has tables and rows and data within it.
Provided that I have the following result set from a mysql database table: +----+------+-------+

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.