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”.

This entry was posted in Programming and tagged , , , , . Bookmark the permalink.

5 Responses to Update Multiple Rows At Once With Different Values in MySQL

  1. Jules Manson says:

    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

  2. stuporglue says:

    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!

  3. 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

  4. anon says:

    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` = CASE
    WHEN `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 ?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>