2010-04-21 56 views
1

我需要更新具有不同值的多行。是否可以在mysql中執行? 即一些這樣的事使用單個mysql查詢的多個更新

UPDATE landing_page SET (rotation_slot_begin='0',rotation_slot_end='0.333333333333' where landing_pageid=265),(rotation_slot_begin='0.333333333333',rotation_slot_end='0.666666666667' where landing_pageid=267),(rotation_slot_begin='0.666666666667',rotation_slot_end='1' where landing_pageid=268) 

但此查詢不working.I認爲像this.Anybody可以幫我請

+1

你不能這樣做。這不是'UPDATE'語句的目的。如果必須爲多行更改不同的值,則必須使用多個語句。 – 2010-04-21 11:17:23

回答

2

Here是我之前發佈的解決方案。

+0

+1。很好,以前從未見過。 – 2010-04-21 11:32:22

0

更新查詢只能有一個WHERE子句,所以你不能以這種方式更新多行。

請參閱documentation

+0

thanks.this文檔我已經referent.if任何人都知道任何其他方式來解決,那可能會有所幫助。再次感謝 – abhis 2010-04-21 11:23:56

+0

@Lex提供的答案中提供的鏈接似乎很有用。也許在一個查詢中解釋嘗試這樣做的原因可能有助於替代想法。 – 2010-04-21 11:28:52

0

你可以使用這種情況。以this thread爲例。

就我個人而言,我會在這種情況下創建並執行3個單獨的查詢。