Hi all:
I need some assistance please. I'm developing an ASP search page for a website and I'm having problems writing an SQL query statement that returns the results accurately.
Here is what I currently have:
If you search for a property only by keyword ("s" the results returned are accurate. If you search for a property only by agent1 or agent2, the results are accurate.
If you search for a property by keyword AND by agent, the results show properties which have either the keyword OR the agent is in agent2 field.
How can I combine the querystring so that it pulls only results that include the keyword AND the agent, whether the agent is agent1 or agent2?
I need some assistance please. I'm developing an ASP search page for a website and I'm having problems writing an SQL query statement that returns the results accurately.
Here is what I currently have:
Code:
MSQL = "SELECT * FROM properties WHERE act = 'Active' "
If Not Request.Querystring("s") = "" Then
qs = Split(Request.Querystring("s"), " ")
For i = 0 to UBound(qs)
MSQL = MSQL & "AND pr_desc LIKE '%" & qs(i) & "%' "
Next
End If
If Not Request.Querystring("ag") = "" And Not Request.Querystring("ag") = "all" Then
ag = Request.Querystring("ag")
MSQL = MSQL & "AND pr_agent = " & ag & " OR pr_agent2 = " & ag & " "
End If
If you search for a property by keyword AND by agent, the results show properties which have either the keyword OR the agent is in agent2 field.
How can I combine the querystring so that it pulls only results that include the keyword AND the agent, whether the agent is agent1 or agent2?