You are currently browsing comments. If you would like to return to the full story, you can read the full entry here: “Update Multiple Rows At Once With Different Values in MySQL”.
You are currently browsing comments. If you would like to return to the full story, you can read the full entry here: “Update Multiple Rows At Once With Different Values in MySQL”.
Very good post. I was looking for something exactly like this. My PHP is fairly good so I didn’t need the PHP part but I definitely needed to see how to write a MySQL statement that does exactly this.
May I ask, do you know or use MySQLi prepared statements? If so I would love to see an article exactly like this using prepared statements. I find writing the php for MySQLi prep statements a bit tricky.
Thanks again for a great post.
Jules
I’m happy that this was helpful to you!
–
“May I ask, do you know or use MySQLi prepared statements? If so I would love to see an article exactly like this using prepared statements.”
I’m aware of prepared statements, but I haven’t actually used them. Sorry!
Hi,
You are a genious been looking for something like this.
Really helpful and kind of you to put an example of such.
I have put the PHP code around it and works a treat. :-)
Thanks
Steve
Thank you so much for writing this, this is literally the only article I could find anywhere that spelled it out simply.
I wasn’t quite sure about the ELSE parts though. For example you put
`column3` = CASEWHEN `id`='1034786' THEN 'Text One'
WHEN `id`='1037099' THEN 'Text Two'
WHEN `id`='1034789' THEN 'Text Three'
ELSE `title` END
Surely it should be ELSE `column3` END ?
Yes, you’re correct.
I anonymized some private code so it would make more sense in the blog post, and missed that one. Fixing it now.