Avatar of fcruz5
fcruz5Flag for United States of America

asked on 

Update & Delete from multiple tables in PHP?

How do I update & delete from multiple tables in one query? What is the best way to do this?

Lets say I want to DELETE from table1, table2, table3, table4

and

UPDATE fields 1-5 on both table5 & table6
<?php
require('db.php');
 
mysql_query("DELETE FROM table1");
 
mysql_query("UPDATE table5 SET field1='', field2='', field3='', field4='', field5='' ");
 
mysql_close();
exit();
?>

Open in new window

PHP

Avatar of undefined
Last Comment
Michael701
ASKER CERTIFIED SOLUTION
Avatar of Khanh Doan
Khanh Doan
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of Michael701
Michael701
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo