3
我有7個SQL查詢來執行這樣的任務:將7個SQL查詢寫入單個查詢中,這可能嗎?
1. UPDATE Customer SET CustomerService = 'perta' WHERE FirstName = 'john';
2. UPDATE Customer SET Flag = 1 WHERE OrderNum BETWEEN 2 AND 29;
3. UPDATE Customer SET PurchaseNum = PurchaseNum + 60 WHERE OrderNum BETWEEN 2 AND 29;
4. UPDATE Customer SET OrderNum = OrderNum + 60 WHERE OrderNum BETWEEN 2 AND 29;
5. UPDATE Customer SET PurchaseNum = PurchaseNum - 28 WHERE (PurchaseNum > 29 AND PurchaseNum <= 89) AND (Flag <> 1);
6. UPDATE Customer SET OrderNum = OrderNum - 28 WHERE (OrderNum > 29 AND OrderNum <= 89) AND (Flag <> 1);
7. UPDATE Customer SET Flag = 0 WHERE OrderNum BETWEEN 62 AND 89;
是有可能「壓縮」的SQL查詢到1查詢?
因爲恐怕用戶按下ESC按鈕(在他/她按下SUBMIT按鈕之後)取消了這個過程,那麼這些序列將在中間被打破,我的桌子也會變得混亂。
使用交易! (以及支持它們的存儲引擎) – Mat 2012-04-11 09:40:26
爲什麼不使用事務? – 2012-04-11 09:40:47
聽說過交易?此外,一旦客戶端發出HTTP請求,他不能去切斷傳輸請求的線路...... – Baz1nga 2012-04-11 09:40:59