Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Delete Multiple records

Explorer ,
Sep 29, 2008 Sep 29, 2008

Copy link to clipboard

Copied

Hey there,

This is the stock code from DMX being a delete record from one table

if ((isset($_GET['recordID'])) && ($_GET['recordID'] != "")) {
$deleteSQL = sprintf("DELETE FROM sitedata WHERE siteid=%s",
GetSQLValueString($_GET['recordID'], "int"));

mysql_select_db($database_bcmain, $bcmain);
$Result1 = mysql_query($deleteSQL, $bcmain) or die(mysql_error());

$deleteGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}

but how can i make that delete from 3 tables simultaneously?

the other tables being

$deleteSQL = sprintf("DELETE FROM sitedata WHERE siteid=%s",
GetSQLValueString($_GET['recordID'], "int"));

AND
$deleteSQL = sprintf("DELETE FROM sitecomment WHERE siteid=%s",
GetSQLValueString($_GET['recordID'], "int"));

AND
$deleteSQL = sprintf("DELETE FROM sitetag WHERE siteid=%s",
GetSQLValueString($_GET['recordID'], "int"));

I hope that makes sense

Thanks
TOPICS
Server side applications

Views

352
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 29, 2008 Sep 29, 2008

Copy link to clipboard

Copied

Use referential integrity in your database. That way, you only need issue
one delete command and all 3 related tables will be effected. As far as I
know, MySQL does support RI or perhaps someone can tell me different as I
come from the SQL Server camp.

"Prellyan Luxtintner" <webforumsuser@macromedia.com> wrote in message
news:gbqkb6$8cs$1@forums.macromedia.com...
> Hey there,
>
> This is the stock code from DMX being a delete record from one table
>
> if ((isset($_GET['recordID'])) && ($_GET['recordID'] != "")) {
> $deleteSQL = sprintf("DELETE FROM sitedata WHERE siteid=%s",
> GetSQLValueString($_GET['recordID'], "int"));
>
> mysql_select_db($database_bcmain, $bcmain);
> $Result1 = mysql_query($deleteSQL, $bcmain) or die(mysql_error());
>
> $deleteGoTo = "index.php";
> if (isset($_SERVER['QUERY_STRING'])) {
> $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
> $deleteGoTo .= $_SERVER['QUERY_STRING'];
> }
> header(sprintf("Location: %s", $deleteGoTo));
> }
>
> but how can i make that delete from 3 tables simultaneously?
>
> the other tables being
>
> $deleteSQL = sprintf("DELETE FROM sitedata WHERE siteid=%s",
> GetSQLValueString($_GET['recordID'], "int"));
>
> AND
> $deleteSQL = sprintf("DELETE FROM sitecomment WHERE siteid=%s",
> GetSQLValueString($_GET['recordID'], "int"));
>
> AND
> $deleteSQL = sprintf("DELETE FROM sitetag WHERE siteid=%s",
> GetSQLValueString($_GET['recordID'], "int"));
>
> I hope that makes sense
>
> Thanks
>


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 29, 2008 Sep 29, 2008

Copy link to clipboard

Copied

LATEST
thanks but how do i do that - each table has the same id field in it however so the record selection is ok it is just the actual delete command itself

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines