I am having trouble with this small bit of sql I am using for a
homepage.
            I need to select information on the next two events from two
separate tables; tblevents (which holds event related info), and
tbleventdate (which holds info related to each date, including times and
information) herein lies the problem:
By using two separate tables (something that is required) I need to use
a foreign key in tbleventdate.  This foreign key is the key of
tblevents, so when multiple dates occur for the same event (the reason
for two tables), this foreign key is duplicated.  When an event occurs
on consecutive days, it will appear twice, being the only event seen
(LIMIT 2).  What I want is the next event which does not have the same
eventid.  And, just to clarify, it will not work if I say WHERE…
>=varDate, tblevents.eventid != tbleventdate.eventid (as this would
return nothing)
SELECT tblevents.eventid, tblevents.eventdescr, tblevents.eventname,
tbleventdate.eventdate, tbleventdate.timeinfo, tbleventdate.eventid,
tbleventdate.dateid, left(tblevents.eventdescr, 150)
FROM tbleventdate, tblevents
WHERE tblevents.eventid = tbleventdate.eventid AND
tbleventdate.eventdate >= varDate
ORDER BY tbleventdate.eventdate DESC LIMIT 2
 
***Note: varDate is defined as <?php date(Y-m-d) ?>
*** which returns YYYY-MM-DD
 
Thank you in advance

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.2/29 - Release Date: 6/27/2005


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.2/29 - Release Date: 6/27/2005
 

Reply via email to