2011-02-13 56 views
2

如果我們說我想在單個SQL查詢中更新2行或更多行,我該怎麼做?是我這是不工作電流聲明如下:SQL在單個查詢中更新多行

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

+4

請查找「SQL注入」和參數化查詢 – 2011-02-13 06:46:09

回答

2

像這樣的東西應該工作...你做必須修改它一點點

"UPDATE PricePlan 
     SET price = 
       IIf(PricePlanName = 'Guest',"+ GuestInput.Text + ", 
        IIf(PricePlanName = 'Member',"+ MemberInput +"))" 
+0

收到以下錯誤: 「查詢表達式中的語法錯誤(缺少運算符)'CASE WHEN(PricePlanName ='Guest')THEN'3.00'WHEN(PricePlanName ='Member'THEN'2.00'END' – pacheco 2011-02-13 06:51:07