Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 MOD - Recent Topics (was BUG? Recent Topics)
 New Topic  Topic Locked
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 5

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 21 April 2002 :  11:21:43  Show Profile  Send ruirib a Yahoo! Message
But I guess you can change that:


select r_date , t_subject FROM FORUM_TOPICS LEFT JOIN FORUM_REPLY ON FORUM_TOPICS.TOPIC_ID = FORUM_REPLY.TOPIC_ID
WHERE r_DATE>'20020321201244' AND r_AUTHOR=1
UNION select t_date as r_date,t_subject from forum_topics
WHERE t_DATE>'20020321201244' AND t_AUTHOR=1
ORDER BY r_date DESC;



-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

Aaron S.
Average Member

USA
985 Posts

Posted - 21 April 2002 :  11:22:45  Show Profile  Visit Aaron S.'s Homepage
The R_DATE and T_DATE gets put into one unioned field called R_DATE (it is named after the first stmt).

That new field called R_DATE is then sorted. The result is posts in date order whether they are topics or replies.

You don't need to change T_DATE to R_DATE since the UNION does that for us.

--Aaron



MySubs Email MOD
MOD to Smile Mgr
HotKeys MOD

Edited by - aaron s. on 21 April 2002 11:23:52
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 21 April 2002 :  11:28:23  Show Profile  Send ruirib a Yahoo! Message
Yes, you are right, I forgot that.

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 21 April 2002 :  15:00:00  Show Profile  Send ruirib a Yahoo! Message
Aaron,

Here is a query to get only non-duplicate records adequately sorted. It works. I've tested it:

SELECT DISTINCT FORUM_TOPICS.TOPIC_ID, FORUM_TOPICS.T_SUBJECT, FORUM_REPLY.R_AUTHOR, (SELECT TOP 1 R_DATE FROM FORUM_REPLY WHERE (FORUM_REPLY.TOPIC_ID = FORUM_TOPICS.TOPIC_ID AND FORUM_REPLY.R_AUTHOR=5) ORDER BY R_DATE DESC) AS R_DATE
FROM FORUM_REPLY INNER JOIN FORUM_TOPICS ON FORUM_REPLY.TOPIC_ID=FORUM_TOPICS.TOPIC_ID
WHERE FORUM_REPLY.R_AUTHOR=5

UNION

SELECT FORUM_TOPICS.TOPIC_ID, FORUM_TOPICS.T_SUBJECT, FORUM_TOPICS.T_AUTHOR, FORUM_TOPICS.T_DATE
FROM FORUM_TOPICS LEFT JOIN FORUM_REPLY ON FORUM_TOPICS.TOPIC_ID = FORUM_REPLY.TOPIC_ID
WHERE FORUM_TOPICS.T_AUTHOR=5 AND FORUM_REPLY.TOPIC_ID Is Null
ORDER BY R_DATE DESC;

Obviously as in the case you posted, this may need aditional columns. I one main advantage here: it doesn't return duplicate records and everything is done in SQL, so it should be faster than using code to filter duplicate records.


-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

Aaron S.
Average Member

USA
985 Posts

Posted - 21 April 2002 :  15:30:02  Show Profile  Visit Aaron S.'s Homepage
This doesn't seem to work for me... it leaves out a couple of postings.

--Aaron



MySubs Email MOD
MOD to Smile Mgr
HotKeys MOD
Go to Top of Page

Aaron S.
Average Member

USA
985 Posts

Posted - 21 April 2002 :  15:41:32  Show Profile  Visit Aaron S.'s Homepage
It seems to not be including topics where the last reply was done by an author that is not the one you are searching on.

--Aaron



MySubs Email MOD
MOD to Smile Mgr
HotKeys MOD
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 21 April 2002 :  16:47:24  Show Profile  Send ruirib a Yahoo! Message
That's not true. It does include. I have several situations like those and the topics are shown. The date shown, however, is not the date of the last post made by the author. Gonna check that again.

I've tested this on my test forum and I can assure you all topics are shown. Maybe check your data again.

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs


Edited by - ruirib on 21 April 2002 16:49:42
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 21 April 2002 :  16:51:52  Show Profile  Send ruirib a Yahoo! Message
Ok. I've checked it and it does miss some topics that were started by the author and to which he didn't reply.
Gotta look at this again.

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 21 April 2002 :  19:04:43  Show Profile  Send ruirib a Yahoo! Message
SELECT DISTINCT FORUM_TOPICS.TOPIC_ID, FORUM_TOPICS.T_SUBJECT, FORUM_REPLY.R_AUTHOR, (SELECT TOP 1 R_DATE FROM FORUM_REPLY WHERE (FORUM_REPLY.TOPIC_ID = FORUM_TOPICS.TOPIC_ID AND FORUM_REPLY.R_AUTHOR=5) ORDER BY R_DATE DESC) AS R_DATE
FROM FORUM_REPLY INNER JOIN FORUM_TOPICS ON FORUM_REPLY.TOPIC_ID=FORUM_TOPICS.TOPIC_ID
WHERE FORUM_REPLY.R_AUTHOR=5

UNION

SELECT DISTINCT FORUM_TOPICS.TOPIC_ID, FORUM_TOPICS.T_SUBJECT, FORUM_TOPICS.T_AUTHOR, FORUM_TOPICS.T_DATE
FROM FORUM_TOPICS AS FORUM_TOPICS LEFT JOIN FORUM_REPLY AS FORUM_REPLY ON FORUM_TOPICS.TOPIC_ID=FORUM_REPLY.TOPIC_ID
WHERE (FORUM_TOPICS.T_AUTHOR=5 AND FORUM_REPLY.TOPIC_ID Is Null) OR (FORUM_TOPICS.T_AUTHOR=5 AND FORUM_REPLY.TOPIC_ID Not In (SELECT TOPIC_ID FROM FORUM_REPLY WHERE R_AUTHOR=5))
ORDER BY R_DATE DESC;

Well this takes care of the missing topics. Regarding the dates I'm beggining to think that it won't be possible to do it in a single SQL instruction. Uummm this is being harder than I expected...

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

Aaron S.
Average Member

USA
985 Posts

Posted - 21 April 2002 :  19:23:02  Show Profile  Visit Aaron S.'s Homepage
That's one heck of a SQL stmt!

I'm sure there is a way to get it to do it all in one stmt, but at some point it's like killing a bug with a grenade.

The pipe delimeted code seems to work fine. I'm going to stick 1000+ topics in my Db to see what happens to performance. If that is fine, then I'm satisfied.

--Aaron


MySubs Email MOD
MOD to Smile Mgr
HotKeys MOD
Go to Top of Page

Aaron S.
Average Member

USA
985 Posts

Posted - 21 April 2002 :  19:25:49  Show Profile  Visit Aaron S.'s Homepage
Here's the stmt that does it all:

SELECT DISTINCT FORUM_TOPICS.TOPIC_ID, FORUM_TOPICS.T_SUBJECT, FORUM_REPLY.R_AUTHOR, (SELECT TOP 1 R_DATE FROM FORUM_REPLY WHERE (FORUM_REPLY.TOPIC_ID = FORUM_TOPICS.TOPIC_ID AND FORUM_REPLY.R_AUTHOR=1) ORDER BY R_DATE DESC) AS R_DATE
FROM FORUM_TOPICS INNER JOIN FORUM_REPLY ON FORUM_TOPICS.TOPIC_ID = FORUM_REPLY.TOPIC_ID
WHERE (((FORUM_REPLY.R_AUTHOR)=1) AND (((SELECT TOP 1 R_DATE FROM FORUM_REPLY WHERE (FORUM_REPLY.TOPIC_ID = FORUM_TOPICS.TOPIC_ID AND FORUM_REPLY.R_AUTHOR=1) ORDER BY R_DATE DESC))>"20020321010101"))

UNION

SELECT DISTINCT FORUM_TOPICS.TOPIC_ID, FORUM_TOPICS.T_SUBJECT, FORUM_TOPICS.T_AUTHOR, FORUM_TOPICS.T_DATE
FROM FORUM_TOPICS LEFT JOIN FORUM_REPLY ON FORUM_TOPICS.TOPIC_ID = FORUM_REPLY.TOPIC_ID
WHERE (((FORUM_TOPICS.T_AUTHOR)=1) AND ((FORUM_TOPICS.T_DATE)>"20020321010101") AND ((FORUM_REPLY.TOPIC_ID) Is Null)) OR (((FORUM_TOPICS.T_AUTHOR)=1) AND ((FORUM_REPLY.TOPIC_ID) Not In (SELECT TOPIC_ID FROM FORUM_REPLY WHERE R_AUTHOR=1)))
ORDER BY R_DATE DESC;

--Aaron



MySubs Email MOD
MOD to Smile Mgr
HotKeys MOD
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 21 April 2002 :  19:33:43  Show Profile  Send ruirib a Yahoo! Message
Why are you hardcoding dates? You lost me there...

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

Aaron S.
Average Member

USA
985 Posts

Posted - 21 April 2002 :  19:35:50  Show Profile  Visit Aaron S.'s Homepage
Remove the hard coded date with the variable for the date you want to search on (i.e. last 30 days), and voila.

--Aaron



MySubs Email MOD
MOD to Smile Mgr
HotKeys MOD
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 21 April 2002 :  19:46:03  Show Profile  Send ruirib a Yahoo! Message
Sorry Aaron, I don't think the change will give you the date for the last reply by the user. It will give you the date for the last post on the topic, for topics with replies by the user you are looking for, and that leaves us almost where we started.

I'd like this to work, but it's still not working...

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

Aaron S.
Average Member

USA
985 Posts

Posted - 21 April 2002 :  19:49:52  Show Profile  Visit Aaron S.'s Homepage
Hmmm...

It seems to be ordering the data in the correct order... and the same order as the bubble sort page & the first UNION page that I created.

I'll try it with more test data to see if I can find a problem.

--Aaron

MySubs Email MOD
MOD to Smile Mgr
HotKeys MOD
Go to Top of Page
Page: of 5 Previous Topic Topic Next Topic  
Previous Page | Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.4 seconds. Powered By: Snitz Forums 2000 Version 3.4.07