So you're saying there's no actual DELETE statement for this? There is no
way in hell I can write any SQL to do that?? Thats sucks....... :(
Thanks for the example, but how do I run it? I've only used PHP for taking
information out of a database and other simple MySQL queries so while your
Perl example kinda makes sense, I don't understand how to work it. Do I
just put that in a file and run open the file in a browser?
Thanks!
sunny
At 08:12 29/03/02 -0700, Rodney Broom wrote:
>Good morning Sunny,
>
>
>From: sunny <[EMAIL PROTECTED]>
>
> > ...substituting SELECT with DELETE doesn't work :(
>
>That's right, that's how MySQL works. And it doesn't support sub-queries
>for this case, either. So you can't say:
>
> delete from table where field in (select field from other_table)
>
>I'd suggest doing this from another language, like Perl. For instance:
>
> $list_list = $dbh->selectall_arrayref(qq{
> SELECT messages.topicid
> FROM messages
> LEFT OUTER JOIN main
> ON messages.topicid=main.topicid
> WHERE main.topicid is null
> });
>
> for my $row ( @{$list_list} ) {
> $dbh->do(qq{DELETE FROM messages WHERE topicid = $row->[0]});
> }
>
>
>Note, my example is rough, and not tuned for performance. But you get the
>idea. Hollar if you still need a hand with this.
>
>
>
>---
>Rodney Broom
>Programmer: Desert.Net
>
>
>
>
>---------------------------------------------------------------------
>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
---------------------------------------------------------------------
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