Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Help on simple SQL issue
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Help on simple SQL issue

 Post Reply Post Reply
Author
Chris View Drop Down
Newbie
Newbie
Avatar

Joined: 01 March 2003
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote Chris Quote  Post ReplyReply Direct Link To This Post Topic: Help on simple SQL issue
    Posted: 16 May 2003 at 11:02am

What's wrong with my SQL here?

I want to retrieve a specific (pre-known) post from the WWF7 db.

strSQL = "SELECT TOP 1 Thread_ID, Topic_ID, Message, Message_date FROM "
strSQL = strSQL & "tblThread WHERE "
strSQL = strSQL & "Topic_ID = 128 " 
strSQL = strSQL & "Thread_ID = 391"
strSQL = strSQL & " ORDER BY Message_date DESC"
Set rsThreads = connectForum.Execute(strSQL)

I always get the same (wrong) post from Topic_ID = 128, namely the last one posted. Even if I change the last SQL-line to ORDER BY Message_date ASC the result is the same.

I'd really appriciate any suggestions!

Chris

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2003 at 11:14am
Does the thread have more than one post?
The line
strSQL = strSQL & "Thread_ID = 391"
is redundant as the Topic_ID is the primary key so specifying it should guarantee the same posts as with the strSQL = strSQL & "Thread_ID = 391"
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2003 at 11:30am

strSQL = strSQL & " AND Thread_ID = 391"

Theres no way your posted SQL script should have worked, the above should

and if it doesn't, then Response.Write (and Response.End right after that) out the variable holding the script and confirm its correct

Contribute to the working anarchy we fondly call the Internet
Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2003 at 2:58pm

strSQL = "SELECT Thread_ID,  Message, Message_date "
strSQL = strSQL & "FROM tblThread "
strSQL = strSQL & "WHERE Thread_ID = 391"

The above is all you need to get that post...

FeRnAN
Back to Top
Chris View Drop Down
Newbie
Newbie
Avatar

Joined: 01 March 2003
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote Chris Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2003 at 3:20pm

Thanks!

But when I display the Message an annoying tag is attached to it, like User234234,2342525622231. How do I get rid of that?

I now use
strMessage = rsThreads.Fields("Message").Value

for putting the Message in variable strMessage and

Response.Write(vbCrLf & strMessage & vbCrLf)

for displaying it. Any other (better) suggestions?

Chris

 

Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2003 at 5:56pm

try

strMessage = rsThreads("Message")

FeRnAN
Back to Top
Chris View Drop Down
Newbie
Newbie
Avatar

Joined: 01 March 2003
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote Chris Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2003 at 6:43pm

Nope, that doesn't make the trick. The trace of the user who posted the message seem to be smuggled into strMessage anyway, a really ugly string like User312331,312512512312

There must be an evil Ghost inside my machine...  

Chris

Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2003 at 7:49pm
post the full code and a link to the page...
FeRnAN
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 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 Notice

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 at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

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