List:General Discussion« Previous MessageNext Message »
From:Rafal Jank Date:June 20 2002 3:15pm
Subject:Re: multi-table delete
View as plain text  
> Hi,
> 
> I'm rather new to mySQL, so maybe that's the problem, but here it goes:
> I'm using version 4.0.1 alpha-max-nt running on W2k server
> the tables I'm using
> 
>     CREATE TABLE `customers` (
>   `CustomerID` int(11) NOT NULL auto_increment,
>   `FullName` varchar(50) default NULL,
>   `EmailAddress` varchar(50) default NULL,
>   `Password` varchar(50) default NULL,
>   PRIMARY KEY  (`CustomerID`)
> ) TYPE=MyISAM;
> 
>     CREATE TABLE `orderdetails` (
>   `OrderID` int(11) NOT NULL default '0',
>   `ProductID` int(11) NOT NULL default '0',
>   `Quantity` int(11) default '0',
>   `UnitCost` decimal(19,4) default '0.0000',
>   PRIMARY KEY  (`OrderID`,`ProductID`)
> ) TYPE=MyISAM;
> 
> CREATE TABLE `orders` (
>   `OrderID` int(11) NOT NULL auto_increment,
>   `CustomerID` int(11) default '0',
>   `OrderDate` datetime default '0000-00-00 00:00:00',
>   `ShipDate` datetime default '0000-00-00 00:00:00',
>   PRIMARY KEY  (`OrderID`)
> ) TYPE=MyISAM;
> 
> I'm trying to delete Customer 19 and all related orders (in table orders and
> orderdetails) in one statement (don't even know for sure if it's possible).
> After reading the documentation I've come up with this:
> 
> DELETE Customers, orderdetails, orders FROM
> Customers, orderdetails, orders
> WHERE Customers.customerid & orders.CustomerID =19;
Try this (I haven't tried this, but maybe that will help):
DELETE Customers, orderdetails, orders FROM
Customers, orderdetails, orders
WHERE Customers.customerid =19 and 
orders.CustomerID =19 and
orderdetails.orderid=orders.OrderId;
 

-- 
_/        _/  _/_/_/  -----     RafaƂ Jank rjank@stripped     -----
 _/  _/  _/  _/   _/         Wirtualna Polska SA   http://www.wp.pl 
  _/_/_/_/  _/_/_/    ul. Traugutta 115c, 80-237 Gdansk, tel/fax. (58)5215625
   _/  _/  _/         --------==*  http://szukaj.wp.pl *==----------
Thread
multi-table deleteAnibal Cascais Santos20 Jun
  • Re: multi-table deleteRafal Jank20 Jun
  • Re: multi-table deleteAnibal Cascais Santos20 Jun
  • RE: multi-table deleteOladapo Carew20 Jun
    • Re: multi-table deleteAnibal Cascais Santos20 Jun
Re: multi-table deleteAnibal Cascais Santos20 Jun