Forum Moderators: open

Message Too Old, No Replies

SQL Statement - need help

sql statement

         

andchr

9:33 am on Apr 9, 2003 (gmt 0)

10+ Year Member



Hello,

I have the following SQL statement:

sql="select * from [tblbuy] where Location like '%" & replace(request("location"),"'","''") & "%' and NoBedrooms like '%" & replace(request("NoBedrooms"),"'","''") & "%' and Price between" & request("fromprice") & " and " & request("toprice") & "%'"

I'm getting the following error:

Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression 'Location like '%leeds%' and NoBedrooms like '%4%'and Price between1000 and 200000%''.

it seems is getting the requested values but something is missing in the between statement.

Appriciate if anyone can help me.

Thanks
Andreas

le_gber

9:49 am on Apr 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



sql="select * from [tblbuy] where Location like '%" & replace(request("location"),"'","''") & "%' and NoBedrooms like '%" & replace(request("NoBedrooms"),"'","''") & "%' and Price between" & request("fromprice") & " and " & request("toprice") & "%'"

Just a thought but where is the corresponding ' from your last 4 characters? Also what is the last % used for?

leo

Dreamquick

9:57 am on Apr 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What le_gber said, plus "spaces"?

Your post said;

Syntax error (missing operator) in query expression 'Location like '%leeds%' and NoBedrooms like '%4%'and Price between1000 and 200000%''

Would this statement work any better?

Location like '%leeds%' and NoBedrooms like '%4%' and Price between 1000 and 200000

Specifically the first space @ '%4%'and, and the second space @ between1000, plus the fixes le_gber suggested.

- Tony

WebJoe

9:57 am on Apr 9, 2003 (gmt 0)

10+ Year Member



I just noticed that you are missing a space in

Price between" & request("fromprice")

(after the keyword "between")

andchr

10:05 am on Apr 9, 2003 (gmt 0)

10+ Year Member



Thank so much for your help
It worked

I try to remove that before and i was getting data missmatch and i remember that the price field in MS Access was text not number, i change that to number and is working fine now.

I post my Final SQL statement may helpful to anyone having similar problems in the future.

sql="select * from [tblbuy] where Location like '%" & replace(request("location"),"'","''") & "%' and NoBedrooms like '%" & replace(request("NoBedrooms"),"'","''") & "%' and Price between " & request("fromprice") & " and " & request("toprice")

Thanks again for your help
Andreas

le_gber

10:25 am on Apr 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad we could help! Aren't we? :)

Leo