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 > Database Server Software > Other > The right SQL-statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-02-03, 03:25
Sovetryne Sovetryne is offline
Registered User
 
Join Date: Sep 2003
Location: Denmark
Posts: 9
Exclamation 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 ( 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 11-25-03, 04:26
satish_ct satish_ct is offline
Registered User
 
Join Date: Nov 2003
Location: Bangalore, INDIA
Posts: 333
HI,

Try with this Query

SELECT ID
, ReplyID
, Name
, Email
, IP
, Subject
, Text, Date
, Time
, Position
, BaseID
FROM forum
ORDER BY BaseID
, ID
, Date
, Time ASC
;
__________________
SATHISH .
Reply With Quote
  #3 (permalink)  
Old 11-25-03, 04:50
Sovetryne Sovetryne is offline
Registered User
 
Join Date: Sep 2003
Location: Denmark
Posts: 9
Cool Thanks

Thanks for the reply. I already tried that one, but thanks anyway.
Together with an expert from Denmark, I got a solution, which is much more complicated than just an SQL-query.

Yours sincerely,


Sovetryne
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On