Re: Newbie Question: Convert SELECT to DELETE statement in mysql
| From: | Heikki Tuuri | Date: | Fri, 19 Oct 2001 08:11:03 +0000 |
| Subject: | Re: Newbie Question: Convert SELECT to DELETE statement in mysql | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-13519@lists.php.net to get a copy of this message | ||
Hi!
In MySQL-4.0.0 you can delete from several tables in a join:
DELETE t1, t2 FROM t1, t2, t3 WHERE ...;
But 4.0.0 is still alpha, and it will take some months for it to
stabilize. No compact or defrag is normally needed with
MySQL.
Regards,
Heikki
http://www.innodb.com
Shaun Honsvick wrote in message <20011018233433.62487.qmail@pb1.pair.com>...
>No, I am not trying to delete with a select statement. That was just there
>to show my tables, fields, etc.
>
>So if I understand what you are saying I can not do a delete statement with
>a join in it. I would have to query each individual row for the ID that
need
>to be deleted, delete the row in the first table, then delete the row in
the
>second table, third table, etc. Then loop for the next intance. Theres got
>to be a better way. Also, after this is done should I run some sort
compact
>or defrag on the database that restore wasted space?
>
>Thanks,
>Shaun
>
>
>"Rick Emery" <remery@excel.com> wrote in message
>——µXÓ°F¼�lŒ
>–†ònews:EAA093B474ABD311A71E00508B5FE08305C2CAB5@adntex03.us.excel.com...
>> Are you trying to delete records with a SELECT statement? That can't be
>> done.
>>
>> To delete from two different tables, you must use two different DELETE
>> statements.
>>
>> -----Original Message-----
>> From: Shaun Honsvick [mailto:shonsvick@ce-group.com]
>> Sent: Tuesday, October 16, 2001 3:59 PM
>> To: php-db@lists.php.net
>> Subject: [PHP-DB] Newbie Question: Convert SELECT to DELETE statement in
>> mysql
>>
>>
>> I am trying to run a delete on a mysql database. The delete query needs
to
>> delete from 2 tables. The select statement is:
>>
>> SELECT tinvoices.*, ttrackingnumbers.* FROM tinvoices LEFT JOIN
>> ttrackingnumbers ON tinvoices.InvoiceID = ttrackingnumbers.InvoiceID
WHERE
>> Date < '2001-08-01';
>>
>> I can't seem to get a delete statement to work. (This is my first
project)
>>
>> Thanks,
>> Shaun
>>
>>
>>
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
>> For additional commands, e-mail: php-db-help@lists.php.net
>> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>>
>
>