Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 3rd, 2006, 07:15 AM
Authorized User
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default Which SQL Function?

Hello,
I have a form with 2 list menus: minAge & maxAge.

On my results page, I want to 'filter' out people whose AGE falls between the two (>= minAge & <=maxAge).

Do I use the BETWEEN or the 'AND OR' SQL function. EG:

myMin = CInt(Request("minAge"))
myMax = CINT(Request("maxAge"))
mySQL = "SELECT * From tblstaff WHERE BrAge BETWEEN '" & myMin & "' AND '" & myMax & "'"


Hope to hear (& is this the better way?)
TIA.

 
Old July 3rd, 2006, 09:29 AM
Friend of Wrox
 
Join Date: Nov 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

The BETWEEN operator is fine if you want yo use it. The AND is good to
I've noticed you used the single quote this is not needed because it myMin and myMax are numbers

The Between operator
Code:
' The Between operator
mySQL = "SELECT  * From  tblstaff WHERE  BrAge BETWEEN  " & myMin & " AND  " & myMax
Using AND only
Code:
' The Between operator
mySQL = "SELECT  * From  tblstaff WHERE  BrAge >= " & myMin & " 
AND  BrAge <=" & myMax
the only thing you can't use is OR

__________________________________________________ ________
This is my junk I'm gona eat it
 
Old July 3rd, 2006, 09:53 AM
Authorized User
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you.
That makes sense now!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Sql Server Function Creation Arunachalam SQL Server 2000 5 May 31st, 2006 10:10 AM
SQL Query - VAL Function itHighway Classic ASP Databases 2 February 23rd, 2005 11:55 PM
Is there an IIF Function in SQL Server? treadmill Classic ASP Professional 4 January 17th, 2005 06:57 AM
sql server function mateenmohd SQL Server 2000 1 June 12th, 2003 04:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.