[thelist] MySql - checking two tables at once.

Warden, Matt mwarden at mattwarden.com
Sun Jan 6 01:46:54 CST 2002

On Jan 6, Martin Kuplens-Ewart had something to say about RE: [thelist]...

>To delete it from both tables... 
>Try the following:
>$dbh=$db->do("DELETE FROM tblAdvise, tblEmails WHERE
>tblAdvise.Email = tblEmails.Email AND
>tblEmails.Email='".sqlEncode($form{'EMAIL'}) ."' ");
>That should do the trick in one delete

you sure? what if the email isn't in one of the tables? if this is legal
syntax (and i'm not sure it is), then it seems to be saying "delete the
rows where the email address is found in both tables" and I don't believe
this is what he wanted. He wants to delete the address in either table if
it exists. so, assuming you can delete from multiple tables like you
suggest, he'd want something liek this:

delete from tblAdvise, tblEmails where tblAdvise.Email = '$email' or
tblEmails.Email = '$email';



More information about the thelist mailing list