tags:

views:

26

answers:

3

I need to update multiple rows with different values.Is it possible to do in mysql? ie,some thing like this

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)  

but this query is not working.I think something like this.Anybody can help me please

A: 

An UPDATE query can only have one WHERE clause so you can't update multiple rows in that way.

See documentation.

Jarod Elliott
thanks.this documentation i already refered.if anybody know any other way to solve,then that may be helpful.thanks again
Ajith
The link provided in the answer provided by @Lex seems useful. Maybe explaining the reason for trying to do this in one query might help with alternate ideas.
Jarod Elliott
A: 

You could use cases for this. Take a look at this thread for an example.

Personally, I would create and execute 3 seperate queries in this case.

Lex
+2  A: 

Here is the solution I have already posted before.

newtover
+1. Nice, never seen that before.
Jarod Elliott