2

If let's say i would like to update 2 or more rows in a single SQL query, how can i do that? My current statement which is not working are as follows:

UPDATE PricePlan SET Price='" + GuestInput.Text + "' WHERE PricePlanName = 'Guest' THEN Price='" + MemberInput.Text + "' WHERE PricePlanName = 'Member'

1
  • 4
    please lookup 'SQL Injection" and parameterised queries. Commented Feb 13, 2011 at 6:46

1 Answer 1

2

Something like this should work...you make have to modify it a little bit

"UPDATE PricePlan 
       SET price =
                 IIf(PricePlanName = 'Guest',"+ GuestInput.Text + ",
                   IIf(PricePlanName = 'Member',"+ MemberInput +"))"
Sign up to request clarification or add additional context in comments.

3 Comments

received the following error: "Syntax error (missing operator) in query expression 'CASE WHEN (PricePlanName = 'Guest') THEN '3.00' WHEN (PricePlanName = 'Member' THEN '2.00' END'
@pacgeco IFF is synonymous to case in ms access...try now
There's a missing parenthesis after 'member'. Try fixing it or just remove every paranthesis, in this case are unnecesary

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.