on 12/29/03 9:54 AM, Dave G wrote:

> $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);

One extra join will do it. You're looking for all improvws in the next seven days that 
aren't cancelled, right?

$query = "SELECT members.email, members.firstname, members.lastname FROM improvws, 
improvwsattend, members WHERE improvws.wsdate > '$today' AND improvws. wsdate < 
'$sevenDays' AND improvws. cancelled=0 AND improvws.wsid = attend.improvwsid AND 
attend.attendeeid = members.id"

Also, are you sure you don't want >= and <= ?

> 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.

That's because you were being inefficient. :)

-- 
Bob
IQ2GI5SCP2

Things You Don't Hear Every Day, #'s 16 and 17:
A professor: "It's all right if you come to class high."
A(nother) professor: "I think base 16 is cool."
--

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

Reply via email to