|
| |
|
|
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
|
|
|
|
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
|
|
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
|
|
|