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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:56:13+00:00 2026-05-31T01:56:13+00:00

tableOk so what I want to do is the following I have multiple tables

  • 0

tableOk so what I want to do is the following

I have multiple tables on one database in mysql

database1

table1

table2

table3

table4

table5

each table has a column id

for every id matched i want to delete that row. so delete 954001 row in every table. What is the best way to do this WITHOUT killing my database. Btw all ids match across the board.

<?php
// get value of id that sent from address bar
$customer_id=$_GET['id'];
$id=$_GET['id'];
// Delete data in mysql from row that has this id
$sql="DELETE FROM teable_users WHERE customer_id = $customer_id;
DELETE FROM table_parties WHERE id = $id;
DELETE FROM table_weddings WHERE id = $id;
DELETE FROM table WHERE id = $id;
DELETE FROM table_request_client WHERE id = $id;
DELETE FROM table_requests WHERE id = $id;
DELETE FROM table_users WHERE id = $id;";

$result=mysql_query($sql);

// if successfully deleted
if($result){
echo "Deleted Successfully";
echo "<BR>";
echo "<a href='text.php'>Back to Event    Manager</a>";
}

else {
echo "ERROR";
}

// close connection
mysql_close();

?>
  • 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-31T01:56:14+00:00Added an answer on May 31, 2026 at 1:56 am

    You need a DELETE statement for each table. You could use a transaction if you are worried about consistency.

    BEGIN TRANSACTION;
    DELETE FROM table1 WHERE id = 1;
    DELETE FROM table2 WHERE id = 1;
    DELETE FROM table3 WHERE id = 1;
    DELETE FROM table4 WHERE id = 1;
    DELETE FROM table5 WHERE id = 1;
    COMMIT;
    

    PHP example using PDO (not tested)

    $id = (int) $_GET['id'];
    $pdo->beginTransaction();
    $st = $pdo->prepare('DELETE FROM table1 WHERE id = :id');
    $st->execute(array(':id', $id));
    $st = $pdo->prepare('DELETE FROM table2 WHERE id = :id');
    $st->execute(array(':id', $id));
    $st = $pdo->prepare('DELETE FROM table3 WHERE id = :id');
    $st->execute(array(':id', $id));
    $st = $pdo->prepare('DELETE FROM table4 WHERE id = :id');
    $st->execute(array(':id', $id));
    $st = $pdo->prepare('DELETE FROM table5 WHERE id = :id');
    $st->execute(array(':id', $id));
    $pdo->commit();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i mean i have songs table ok?? i want to make some things like
I have a table - ok well three tables artists, venues and events..about 150k
Let's say I have this MySQL table: OK.. see the type field? Type 0
I need to compare values from two tables that are identical but contain some
I know this type of thing I want to do used to work in
What do you think of the following table mapping style for domain entities? class
I have a query where I have to extract some number fields from varchar
I'm developing an Android 3.1 application that uses fragments. On one of those fragments
There is a table with the following stucture: Here are the data in this
I have decided to change a search from using LIKE '%' + @searchTerm +

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.