List:General Discussion« Previous MessageNext Message »
From:Steve Buehler Date:May 23 2002 6:45pm
Subject:Deleting from multiple tables
View as plain text  
I am using MySQL with a PHP front end.  Is there a better way to delete 
from multiple tables than the following?
	$result=mysql_query("DELETE FROM team WHERE team_id = '$team_id'");
	$result=mysql_query("DELETE FROM conflicts WHERE team_id = '$team_id'");
	$result=mysql_query("DELETE FROM home_field WHERE team_id = '$team_id'");

I tried
	$result=mysql_query("DELETE FROM team,conflicts,home_field WHERE team_id = 
But of course, that doesn't work.  Or do all of the tables HAVE TO have the 
$team_id in them for this to work.  The conflicts and home_field tables 
might not have the $team_id in it.  So I either have to do each table 
separately or have to come up with a way to delete from multiple tables 
even if the $team_id is not in the "team_id" column.  Any suggestions?


Deleting from multiple tablesSteve Buehler23 May