Forum Moderators: open

Message Too Old, No Replies

Problem with String within a SQL WHERE statement

Am trying to get a SQL statement to combine WHERE AND + and STR

         

Hobnob

9:54 pm on Dec 15, 2003 (gmt 0)

10+ Year Member



Please if anyone can help:

I'm trying to combine a simple ASP SQL WHERE statement that reads as follows:

SELECT * FROM tbl_Basket WHERE Order_Status="Incomplete" AND Username = '" & str_users_name & "'

as you will see '" & str_users_name & "' should normally return the SQL Username String that is carried...

Have i missed something, or am i just being daft?

Many Thanks in advance :)

J

defanjos

10:10 pm on Dec 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is the problem/error you are getting?

Welcome to WebmasterWorld

RossWal

10:18 pm on Dec 15, 2003 (gmt 0)

10+ Year Member



Welcome to WW!

Try single quotes on the 'Incomplete'.

f00sion

10:24 pm on Dec 15, 2003 (gmt 0)

10+ Year Member



are you sending this command through asp to sql or is this inside a stored procedure?... if its through asp your quotation marks are a little off..should look something like this:
strSql = "SELECT * FROM tbl_Basket WHERE Order_Status='Incomplete' AND Username = '" & str_users_name & "'"

killroy

10:25 pm on Dec 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try flipping the single and double quotes for the username, i.e. singles outside and doubles inside (or vice versa)

SN

Hobnob

12:48 am on Dec 16, 2003 (gmt 0)

10+ Year Member



thanks so much for all the help guys - I was purely being a muppet! single quotes on the 'incomplete' and the " was missing from the end of the statement - doh!

Again, thanks for everything :)

J