[thelist] MYSQL Select from Table(s)

Adrian Fischer adrian at logo-logic.com
Thu Apr 19 23:06:07 CDT 2001


Hi Gang,

Thanks for the tips on db to ms word the other night.  Got it working fine
(haven't got it into word yet but can at least get the info from the db and
have it delimited with what ever I like..just need to work out what is best
for import into word as a data file...)

Any way..today's problem is;   I have 3 tables which all contain records
that are not related but they all have an email column.  I want to be able
to pull an email from any of the three if it meets a criteria.

sort of like this:
<snip>
my $db = &dbconnect;
my $dbh=$db->prepare("SELECT State FROM tblAds WHERE Email ='$email'  ");
$dbh->execute();
($docstate) = $dbh->fetchrow_array();
</snip>
($email is the criteria and is passed from another sub)

this works for "tblAds" but I also have "tblDockets" and "tblReward"  I want
to be able to do something like: "SELECT State FROM
tblAds,tbleDockets,tblReward WHERE Email ='$email' " but that doesn't work.
I don't want to have to write three select statements unless there is no
work around.

Any ideas

Thanks

Adrian Fischer






More information about the thelist mailing list