What do you guys think is the best way to delete lots of data from a database, if its spread across many tables?
Would you use
or would you use thisPHP Code:$del = mysql_query("DELETE table1, table2, table3
FROM table1, table2, table3
WHERE table1.user_id ='" . $user_id . "' AND table2.user_id ='" . $user_id . "'AND table3.user_id ='" . $user_id ."'");
PHP Code:$del1 = mysql_query("DELETE FROM table1 WHERE user_id='" . mysql_real_escape_string($user_id)."'");
$del2 = mysql_query("DELETE FROM table2 WHERE user_id='" . mysql_real_escape_string($user_id)."'");
$del3 = mysql_query("DELETE FROM table3 WHERE user_id='" . mysql_real_escape_string($user_id)."'");
if ($del1 and $del2 and $del3) {
echo ('success category deleted<br />' . mysql_affected_rows() . mysql_error() .' affected<br />');
}else{
die('error deleting' . mysql_error() . '');
}
}



.

Bookmarks