Print Page | Close Window

Multiple SQL "where" clauses

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=13874
Printed Date: 30 March 2026 at 3:02pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Multiple SQL "where" clauses
Posted By: ub3rl337ch3ch
Subject: Multiple SQL "where" clauses
Date Posted: 18 February 2005 at 12:29am

I know that when using sql you can go  WHERE blahblahblah AND blahblahblah, and that you can have a where that is dependent on user input, but is it possible to have a query that has multiple user dependent WHERE clauses? Help appreciated




Replies:
Posted By: Phat
Date Posted: 18 February 2005 at 5:34am
Won't somthing like below give you what you want?

SELECT tblAuthor.Username, tblAuthor.User_code, tblAuthor.Password, tblAuthor.Author_email, tblAuthor.Show_email, tblAuthor.Homepage
FROM tblAuthor
WHERE (((tblAuthor.Username)="ddff") AND ((tblAuthor.User_code)="dfdf") AND ((tblAuthor.Password)="dfdf"));

How do want multiple where caluses?



Posted By: michael
Date Posted: 18 February 2005 at 10:20am
You can only have ONE where clause in SQL

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: ub3rl337ch3ch
Date Posted: 20 February 2005 at 5:21pm
I need it to be something like
"SELECT * from x WHERE 1.x=" request.form(1) AND 2.x = request.form(2)
 
That doesn't work becuase it thinks that i'm looking for 1.x equalling "request.form(1) and 2.x = reuqest.form(2)"


Posted By: ub3rl337ch3ch
Date Posted: 20 February 2005 at 5:28pm
Phat, thanks, the brackets thing seems to be working.


Posted By: ub3rl337ch3ch
Date Posted: 20 February 2005 at 11:08pm
gah, I just went back to it and the bloody bracket thing just stopped working... if anyone has any suggestions, i might just be convinced not to throw the computer in front of a truck...


Posted By: Phat
Date Posted: 21 February 2005 at 2:56am
you may want to use or instead of and


Posted By: dj1811
Date Posted: 21 February 2005 at 6:18pm
Originally posted by ub3rl337ch3ch ub3rl337ch3ch wrote:

I need it to be something like
"SELECT * from x WHERE 1.x=" request.form(1) AND 2.x = request.form(2)
 
That doesn't work becuase it thinks that i'm looking for 1.x equalling "request.form(1) and 2.x = reuqest.form(2)"
 
"SELECT * FROM x WHERE 1.x=" & Request.Form("1") & " AND 2.x=" & Request.Form("2")


Posted By: ub3rl337ch3ch
Date Posted: 21 February 2005 at 9:22pm
yeah, ok, i typed that in wrong in the post... I had the quotes for the and 2.x, i just forgot to post them...


Posted By: dj1811
Date Posted: 22 February 2005 at 12:28am

My feeling is you are trying to do this:

table x
ID 1 2
1  a c
2  a d
3  b c
 
You want to select "a" from column 1 and "d" from column 2, so your recordset would be:
 
2  a d
 
To accomplish this is simply :
 
"SELECT * FROM x WHERE 1='" & Request.Form("1") & "' AND 2='" & Request.Form("2") & "'"
 
If that is, in fact, what you are trying to do and it is not working for you, check the syntax carefully.
 
If that isn't what you are trying to do, then need more info. Maybe you could post a quick example of what you are trying to do? Or, are you getting an error message?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net