navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

SQL dB Query ??

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> SQL dB Query ??
Page: [1]
 
WRXSTi

 

Posts: 30
Joined: 2/7/2002
From: MA USA
Status: offline

 
SQL dB Query ?? - 4/5/2002 17:55:43   
I have the following code:
sql = "SELECT items.id, " & _  
"items.subject, " & _
"items.condition, " & _
"items.price, " & _
"items.category, " & _
"items.email, " & _
"items.user, " & _
"items.submit_date, " & _
"items.submit_type " & _
"FROM items " & _
"WHERE ((items.submit_type)='" & sType & "') AND ((items.user)='" & sUser & "');"


In my web page I have two text boxes where visitors will fill in for query conditions. sType is a item condition, new, used, etc, and sUser is the users ID. If a user fills in sType, but not sUser no results will be returned. can I force a '*' in for either sType or sUser for a representation of all results returned ?

Example: Query only used items and from all users? Is there a character or condition I can inser in the where condition or must I remove it for the query example to return all used items of all users.



Me
alveyuk

 

Posts: 80
Joined: 4/4/2002
From: Lincs United Kingdom
Status: offline

 
RE: SQL dB Query ?? - 4/5/2002 18:20:45   
As you are building the SQL in ASP code, the easy way is to build the WHERE clause using IF statements. If sType is populated then include that in the where clause. If sUser is populated then add that into the where clause.

You would need to trap the situation where neither had been supplied to make sure you did not perform an open query.

To get round the problem of whether including sUser started with WHERE or AND depending upon on whether sType was populated, you could start the clause with

WHERE ((1 = 1)

then both of the could always start with (AND items....... etc) and then finish after both IF tests with

)

Ken Alvey

(in reply to WRXSTi)
WRXSTi

 

Posts: 30
Joined: 2/7/2002
From: MA USA
Status: offline

 
RE: SQL dB Query ?? - 4/5/2002 18:46:42   
I see... I'll look in to it. thanks !

Me

(in reply to WRXSTi)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> SQL dB Query ??
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts