If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Calendar Events Table, Very Stuck!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-02-09, 17:21
chricholson chricholson is offline
Registered User
 
Join Date: Mar 2009
Posts: 1
Calendar Events Table, Very Stuck!

Hi,

I'm having a great deal of difficulty with a database for a website, in particular the appropriate method for calling the data I want which makes me question my original design.

I have three tables: Sections, Terms and TermEvents. Sections has just a sectionID and a sectionName. Terms has a termID, termTitle and termStartDate. TermEvents has eventsID, eventTitle, eventDescription, eventDate, termID, sectionID.

From this I get the relationship so that one term can have many events, and one section can be linked with many events. When I come to calling upon it in my application, I need some way to call the most recent term (so using termStartDate < getDate()) and then displaying all the relevant events for that term (so matching the termID from TermEvents with the same as the termID from Terms).

I am trying to use a mixture of ASP VB and ASP Repeaters but this is proving harder than I first imagined. I can call upon a specific term by defining the termID and this displays the correct events. However, I need to find some way to call upon the date of the most recent term, then somehow get the ID of this term and use that to call upon appropriate events. Hoping someone has done something similar!

Many thanks in advance,

Chris
Reply With Quote
  #2 (permalink)  
Old 03-03-09, 03:39
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Code:
SELECT Max(termstartdate) As most_recent_term
FROM   terms
WHERE  termstartdate < GetDate()
Code:
SELECT terms.id
FROM   terms
 INNER
  JOIN (
        SELECT Max(termstartdate) As most_recent_term
        FROM   terms
        WHERE  termstartdate < GetDate()
       ) As x
    ON terms.termstartdate = x.most_recent_term
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On