Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 5th, 2004, 06:52 PM
btphelps btphelps is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Stockton, CA
Posts: 1 btphelps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to btphelps Send a message via AIM to btphelps Send a message via Yahoo to btphelps
Cool Need to add filter to SQL Query

Hi Friends,

I have a series of files for displaying News and Events. Each calls the function--

DisplayNews()

This invokes the function--

XML_News

This function creates an array:

zarrRS = Retrieve_News()

Retrieve_News does the SQL lookup:

Function Retrieve_Index()
'# returns an array of the index posts to be displayed
Dim zstrSQL,tmpPage,zobjRS,zarrRS
'-- basic elements query --
zstrSQL = "SELECT news.PostID, news.Title, news.PostedDate, news.Short, userInfo.UserName, categories.CategoryName FROM userInfo INNER JOIN (news INNER JOIN categories ON news.Category Like categories.Category) ON news.PostedBy Like userInfo.UserID"

The database contains a Table named news, which has a date field "PostEnd" that I want to filter on.

Can you tell me how to add this field to the query so I can show only results whose PostEnd dates are later than the current date?

Thanks for any help you can offer.

Brian
www.phelpstek.com

Reply With Quote
  #2  
Old October 8th, 2004, 09:46 AM
vikramp vikramp is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 7 vikramp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Brian,

I do not know what programming language you are using. Assuming that you are doing it in ASP, you can simply add the where clause to zstrSQL = statement as follows:

zstrSQL = "SELECT news.PostID, news.Title, news.PostedDate, news.Short, userInfo.UserName, categories.CategoryName FROM userInfo INNER JOIN (news INNER JOIN categories ON news.Category Like categories.Category) ON news.PostedBy Like userInfo.UserID WHERE news.PostEnd > '" + CStr(Date()) + "'"

If you are not using ASP, then probably you need to replace Date() and CStr functions with the appropriate functions in the particular language that you are using.

Hope this solves the problem.

Regards,

Vikram

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Need to add filter to SQL Query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT