MySQL Gurus,
        Hello, I am new to this list. I have looked through the archives
and online, but the particulars of my situation still leave me perplexed
as to how to solve this. It may be more of a lack of ability to
logically sort my query than it is an issue of syntax.
        I have three tables. One records members and information about
them, such as their email addresses. Another table keeps track of
classes that the members attend, and in that table is the date of the
classes. The third table records when a member is attending a class.
        What I want to be able to do is select all the email addresses
of all the students who attend a class on a particular date. If I do it
as a two step process in PHP, it works:

$wsQuery = "SELECT improvwsid FROM  improvws WHERE wsdate > '" . $today
. "' AND wsdate < '" . $sevenDays . "' AND cancelled = 0";
$wsResult = mysql_query($wsQuery);
$wsid = mysql_result($wsResult, 0, "improvwsid");
$emailQuery = "SELECT members.email AS email, members.firstname AS
firstname, members.lastname AS lastname FROM members, improvwsattend
WHERE members.id = attend.attendeeid AND attend.improvwsid = " . $wsid;
$emailResult = mysql_query($emailQuery);

        While this is getting the job done, it doesn't sit right because
it feels like I'm being inefficient. There must be a way to get the
results I want in one query. But not only can I not figure out how to do
that, I'm at a loss as to how to describe where my thinking is going
wrong.
        Any help would be much appreciated.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to