Web Wiz - Solar Powered Eco Web Hosting

  New Posts New Posts RSS Feed - SQL Statment "TOP"
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SQL Statment "TOP"

 Post Reply Post Reply
Author
Agni View Drop Down
Newbie
Newbie


Joined: 02 July 2004
Location: Greece
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Agni Quote  Post ReplyReply Direct Link To This Post Topic: SQL Statment "TOP"
    Posted: 01 March 2005 at 4:59pm
I am using the following query which should return the latest (top) 12 Topics in my forum. Curently it shows some prepeated Topic_ID values. (I am using this to add my most recent posts to a XML RSS news feed)

Any help would be very welcome and almost certianly be greeted by loads of free beer!!! Smile
Nathan

PS I am still using Web Wiz Forums version 6.34 - but I love it!


"SELECT     TOP 12 dbo.tblThread.Message, dbo.tblThread.Message_date, dbo.tblThread.Topic_ID, dbo.tblThread.Author_ID, dbo.tblAuthor.Username,
                &n bsp;     dbo.tblTopic.Subject, dbo.tblTopic.Forum_ID
FROM         dbo.tblThread INNER JOIN
                &n bsp;     dbo.tblAuthor ON dbo.tblThread.Author_ID = dbo.tblAuthor.Author_ID INNER JOIN
                &n bsp;     dbo.tblTopic ON dbo.tblThread.Topic_ID = dbo.tblTopic.Topic_ID
ORDER BY dbo.tblThread.Message_date DESC"



Back to Top
sfd19 View Drop Down
Senior Member
Senior Member


Joined: 20 December 2004
Status: Offline
Points: 263
Post Options Post Options   Thanks (0) Thanks(0)   Quote sfd19 Quote  Post ReplyReply Direct Link To This Post Posted: 02 March 2005 at 12:18pm
Not sure what you mean with "latest topics". The topics where the latest replies have been made? The latest 12 new topics that have been created?
Politics, economy & social issues: StudentsforDemocracy.net
Back to Top
Agni View Drop Down
Newbie
Newbie


Joined: 02 July 2004
Location: Greece
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Agni Quote  Post ReplyReply Direct Link To This Post Posted: 02 March 2005 at 1:49pm
Correct sorry, I am using this to create an RSS (XML) feed of the most recent 12 posts main in my forum. Each time a post is made, the code will be run to update the RSS feed
Back to Top
sfd19 View Drop Down
Senior Member
Senior Member


Joined: 20 December 2004
Status: Offline
Points: 263
Post Options Post Options   Thanks (0) Thanks(0)   Quote sfd19 Quote  Post ReplyReply Direct Link To This Post Posted: 02 March 2005 at 1:59pm
And the result should be the twelve latest post, but only those posts that have been made in different topics?

This would be about the same query that is getting used for the 'latest posts' mod for WWF.


Edited by sfd19 - 02 March 2005 at 2:02pm
Politics, economy & social issues: StudentsforDemocracy.net
Back to Top
Agni View Drop Down
Newbie
Newbie


Joined: 02 July 2004
Location: Greece
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Agni Quote  Post ReplyReply Direct Link To This Post Posted: 02 March 2005 at 2:08pm
Yes, but that query does not return the "Author name" or "message". That's why I am trying to join the tables (but unsucessfuly)
Cheers for any help you can offer.

Nathan
Back to Top
sfd19 View Drop Down
Senior Member
Senior Member


Joined: 20 December 2004
Status: Offline
Points: 263
Post Options Post Options   Thanks (0) Thanks(0)   Quote sfd19 Quote  Post ReplyReply Direct Link To This Post Posted: 02 March 2005 at 2:19pm
I am using these two queries to get the 7 last posts and author names (from 7 different topics):

strSQL = "SELECT DISTINCT Top 7 tblTopic.Topic_ID, tblTopic.Subject, tblTopic.Last_entry_date, tblTopic.Forum_ID "
strSQL = strSQL & "FROM tblTopic "
strSQL = strSQL & "ORDER BY tblTopic.Last_entry_date DESC;"
rsCommon.Open strSQL, adoCon

Set rsLastAuthor = Server.CreateObject("ADODB.Recordset")
Do WHILE NOT rsCommon.EOF
        strSQL = "SELECT TOP 1 tblThread.Thread_ID,  tblThread.Message, tblAuthor.Username "   
        strSQL = strSQL & "FROM tblThread INNER JOIN tblAuthor ON tblThread.Author_ID = tblAuthor.Author_ID "
        strSQL = strSQL & "WHERE tblThread.Topic_ID = " & rsCommon("Topic_ID")
        strSQL = strSQL & " ORDER BY tblThread.Thread_ID DESC;"
        rsLastAuthor.Open strSQL, adoCon
......


I added tblThread.message to the second query so it should fit your needs now.
Politics, economy & social issues: StudentsforDemocracy.net
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.07
Copyright ©2001-2024 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Policy

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2024 Web Wiz Ltd. All rights reserved.