2010-04-21 54 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个单独的查询。