I spent some time to do it w/ one query, but I couldn't figure out. So
I am throwing an example in Perl (the best way I could think of)
my $pending = $dbh->selectrow_arrayref(qq/
SELECT pending_2.ordno
FROM pending_2, ordersearch_2
WHERE pending_2.ordno=ordersearch_2.ordno/);
for ( @{$pending} ) {
$dbh->do("DELETE FROM pending_2 WHERE ordno=?", undef, $_);
}
take care
rory o'connor wrote:
ro: Date: Sun, 9 Dec 2001 23:40:03 -0600
ro: From: rory o'connor <[EMAIL PROTECTED]>
ro: To: [EMAIL PROTECTED]
ro: Subject: efficient DELETE query - 2 tables
ro:
ro: I want to write an efficient query that will delete all records from one
ro: table when they show up in another table (pending shipments --> shipped
ro: shipments). I can't do it with this:
ro:
ro: mysql> DELETE from pending_2 WHERE pending_2.ordno = ordersearch_2.ordno;
ro:
ro: because you can only refer to columns of one table in a delete query. Does
ro: anybody have an effiecnt way for me to do this with Perl DBI?
ro:
ro: Thanks!
ro:
ro: Rory
ro:
ro: ---------------------------------------------------------------------
ro: Before posting, please check:
ro: http://www.mysql.com/manual.php (the manual)
ro: http://lists.mysql.com/ (the list archive)
ro:
ro: To request this thread, e-mail <[EMAIL PROTECTED]>
ro: To unsubscribe, e-mail
<[EMAIL PROTECTED]>
ro: Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
ro:
--
Sherzod Ruzmetov <[EMAIL PROTECTED]>
http://www.UltraCgis.com, Consultant
989.774.6265
+----------------------------------------+
| There is nothing wrong with your tools.|
| But we can make a better one. |
+----------------------------------------+
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php