[thelist] MYSQL Select from Table(s)

Darrell King darrell at webctr.com
Fri Apr 20 05:31:12 CDT 2001


<snip>
my $db = &dbconnect;
my $dbh=$db->prepare(
qq|
  SELECT
    tblAds.State AS adsState,
    tblDockets.State AS docketsState,
    tblReward.State AS rewardState
 FROM tblAds,tblReward,tblDockets
 WHERE Email ='$email'
|);
$dbh->execute();
($docstate) = $dbh->fetchrow_array();
</snip>


depending upon the overall purpose, you may wish ti use some LEFT
JOINS or GROUP BYs to organize things...


Darrell


----- Original Message -----
From: "Adrian Fischer" <adrian at logo-logic.com>


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.







More information about the thelist mailing list