1

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

1
  • 1
    You cannot do it this way. This is not the purpose of the UPDATE statement. If you have to change different values for multiple rows, you have to use multiple statements. Commented Apr 21, 2010 at 11:17

3 Answers 3

2

Here is the solution I have already posted before.

Sign up to request clarification or add additional context in comments.

Comments

0

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

See documentation.

2 Comments

thanks.this documentation i already refered.if anybody know any other way to solve,then that may be helpful.thanks again
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.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.