
March 30th, 2007, 06:53 PM
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 1
Time spent in forums: 26 m 23 sec
Reputation Power: 0
|
|
Basic sql statement
new to sql, cant stand it - and dont want to learn anymore than i have to. i have a feeling that this is a very basic concept i am trying to accomplish.
trying to setup a simple web search form through asp, all of the asp stuff is already set
there are 4 input fields, i am trying to combine into an sql statement. any one of the fields can have a blank "" value during the query, using a % as the item value doesn't seem to work when passed through asp....
Basically i need the select statement to return a row matching all of the parameters, or otherwise omitting the parameters that do not have a value.
this is what i came up with in asp, and it only works properly when all fields are specified.
Recordset1.Source = "SELECT * FROM dbo.Residential$ WHERE ([area name] LIKE " & "'" & area & "'" & ") OR (subtype LIKE " & "'" & ptype & "'" & ")" & " OR ([list price] BETWEEN " & "'" & p1 & "'" & "AND" & "'" & p2 & "'" & ")"
so if the passed asp variable is "" (empty) i would like the statement to omit it.
any thoughts?
|