Click to See Complete Forum and Search --> : Search With Multiple Parameter


xesojay
03-09-2006, 05:32 AM
Hi Juys,
Am trying to create a small search engine that will have many options i.e a user can prefer to select option A,B AND C while another might decides to use option A,C,D,F. These options can be selected by using a Check box.
I have seen this kind of search in many website but how to write the query is my problem. Please help me out.

Thanks

Terrorke
03-09-2006, 09:30 AM
You can do this with a 'where'-clause in your sql-query

xesojay
03-09-2006, 10:31 AM
Yes I know but how to construt the query is the issue, e.g if I have ABCDE as options and one user selectABC, then the where clause will look ike this where A=...and B=... and C=... But another user select CDE, then the where clause will look like this where C=... and D=... and E=... . So u now have idea of what am trying to do.

Terrorke
03-09-2006, 12:31 PM
Try something like this :


sql = "select * from Tbl_Table where"

s_a = 0
s_b = 0
s_c = 0


if A = selectedvalue then
sql = sql & " A = '...'"
s_a = 1
end if
If B = selectedvalue then
if s_a = 1 then
sql = sql & " and B = '...'"
else
sql = sql & " B = '...'"
end if
s_b = 1
end if
If C = selectedvalue then
if s_a = 1 or s_b = 1 then
sql = sql & " and C = '...'"
else
sql = sql & " C = '...'"
end if
s_c = 1
end if

....


set RS = db.execute(sql)


Grtz