I figured it out.  I had to add a unique key column to the eventDates table.
Here is the query for archival purposes:

Select eventID, eventName, eventDate from event inner join eventDates on
event.eventID=eventDates.eventID where eventDateID IN (select top 1
eventDateID from eventDates where eventDate>#Now()# and
eventDate.eventID=event.eventID order by eventDate asc) 

Now, the syntax might not be perfect, since I have a different db schema,
but the gist of it should be there.  

Russ

-----Original Message-----
From: Russ [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 16, 2005 5:10 PM
To: CF-Talk
Subject: RE: Query Question

This will return only 1 event... I want all the events, but joined to only 1
record in the eventDates per event... 

So originally the query will return something like this

EventID  eventName    eventDate
1          my event     12/1/2005
1          my event     12/2/2005
1          my event     12/3/2005
1          my event     12/4/2005
1          my event     12/5/2005
2          my other event     12/4/2005
2          my other event     12/5/2005


Where I only want
EventID  eventName    eventDate
1          my event     12/1/2005
2          my other event     12/4/2005

-----Original Message-----
From: Adrian Lynch [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 16, 2005 5:03 PM
To: CF-Talk
Subject: RE: Query Question

I don't know about efficient, but try

SELECT TOP 1 eventID....

That's if it's SQL Server, the over DBs will have something similar

Ade

-----Original Message-----
From: Russ [mailto:[EMAIL PROTECTED]
Sent: 16 November 2005 21:56
To: CF-Talk
Subject: Query Question


I have 2 tables, for the sake of simplification lets say they look like
this:



EVENT

eventID

eventName





EVENTDATES

eventID

eventDate



Each event would be in the event table once, and possibly multiple times in
the eventDates table.  I want to have a query return one record for each
event with the next eventDate from the eventDates table.



So basically something like:



Select eventID, eventName, eventDate from event inner join eventDates on
event.eventID=eventDates.eventID where eventDate>#Now()#



But I only want 1 record returned for each event. I know I can probably
order by eventID and then do a cfoutput groupby, but I don't really want all
those records coming back (I mean it will basically be number of records in
the event table * number of records in the eventDates table).



Is there a more efficient way of doing this?






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:224414
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to