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 > The right SQL-statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-30-03, 15:25
Sovetryne Sovetryne is offline
Registered User
 
Join Date: Sep 2003
Location: Denmark
Posts: 9
Question The right SQL-statement

It seems I am the first on the Internet having a problem with this. So either I am trying something impossible, or I am so stupid that nobody needs to write it down on any homepage.

My problem is some SQL-statement.
I am writing a forum (www.denemarken.prikbord.franl.dk). I use VBScript / ASP as language, and Microsoft Access 2000 as database. I am having MDAC 2.8 installed on my server.
The table in the database has following fields:

- ID (AutoNumber)
- ReplyID (= 0 if a new message is postet, or "ID" of the original message, if the message is a reply)
- BaseID (ID of the first message in a topic range
- Date
- Time
- Subject
- Text
- IP
- Name
- Email
- Position

All subjects are ordered by reply, which means, that a reply on a message appears in a list right under the original message, with to spaces (&nbsp in front of the subject. And if there comes a reply on a reply, it simply adds two more spaces, and appears right under the last message.

Such as these:

Message (ID:1, ReplyID:0, BaseID: 1)
Re: Message (ID:2, ReplyID:1, BaseID: 1)
Re: Message (ID:3, ReplyID:2, BaseID: 1)

Now comes the tricky part. Look at this:

Message (ID:1, ReplyID:0, BaseID: 1)
Re: Message (ID:2, ReplyID:1, BaseID: 1)
Re: Message (ID:3, ReplyID:2, BaseID: 1)
Re: Message (ID:4, ReplyID:3, BaseID: 1)
Re: Message (ID:5, ReplyID:4, BaseID: 1)
Re: Message (ID:6, ReplyID:2, BaseID: 1)
Re: Message (ID:7, ReplyID:6, BaseID: 1)
Re: Message (ID:8, ReplyID:7, BaseID: 1)
Re: Message (ID:9, ReplyID:6, BaseID: 1)
Re: Message (ID:10, ReplyID:9, BaseID: 1)

Now my question is: WHICH SQL Statement am I supposed to use? At this moment, I am using

Select ID, ReplyID, Name, Email, IP, Subject, Text, Date, Time, Position, BaseID from forum ORDER BY BaseID, Position, Date, Time ASC

Yours,

Albert van Harten
Denmark
Reply With Quote
  #2 (permalink)  
Old 09-30-03, 15:30
Sovetryne Sovetryne is offline
Registered User
 
Join Date: Sep 2003
Location: Denmark
Posts: 9
Hmmm, spaces at the beginning of a line do not remain, obviously.

I'll try again, now with underscores in stead of spaces. Please remind to replace the underscores with spaces, in your head

Such as these:

Message______________________________________(ID:1 , ReplyID:0, BaseID: 1)
__Re: Message______________________________(ID:2, ReplyID:1, BaseID: 1)
____Re: Message____________________________(ID:3, ReplyID:2, BaseID: 1)

Now comes the tricky part. Look at this:

Message____________________________________(ID:1, ReplyID:0, BaseID: 1)
__Re: Message______________________________(ID:2, ReplyID:1, BaseID: 1)
____Re: Message____________________________(ID:3, ReplyID:2, BaseID: 1)
______Re: Message__________________________(ID:4, ReplyID:3, BaseID: 1)
________Re: Message________________________(ID:5, ReplyID:4, BaseID: 1)
____Re: Message____________________________(ID:6, ReplyID:2, BaseID: 1)
______Re: Message__________________________(ID:7, ReplyID:6, BaseID: 1)
________Re: Message________________________(ID:8, ReplyID:7, BaseID: 1)
______Re: Message__________________________(ID:9, ReplyID:6, BaseID: 1)
________Re: Message________________________(ID:10, ReplyID:9, BaseID: 1)
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