I understand that you could place multiple rows at the same time, it is possible to method to update multiple rows at the same time (as with, in a single query) in MySQL?

Edit: For instance I've the next

Title   id  Col1  Col2
Row1   1    6     1
Row2   2    2     3
Row3   3    9     5
Row4   4    16    8

I wish to mix all of the following Updates into one query

UPDATE table SET Col1 = 1 WHERE id = 1
UPDATE table SET Col1 = 2 WHERE id = 2
UPDATE table SET Col2 = 3 WHERE id = 3
UPDATE table SET Col1 = 10 WHERE id = 4
UPDATE table SET Col2 = 12 WHERE id = 4

Yes, that's possible - you should use Place ... ON DUPLICATE KEY UPDATE.

Making use of your example:

Place INTO table (id,Col1,Col2) VALUES (1,1,1),(2,2,3),(3,9,3),(4,10,12)

Because you have dynamic values, you should utilize an IF or Situation for that posts to become up-to-date. It will get kinda ugly, however it should work.

Making use of your example, you could do this it like:

UPDATE table SET Col1 = Situation id

                          WHEN 1 THEN 1

                          WHEN 2 THEN 2

                          WHEN 4 THEN 10

                          ELSE Col1


                 Col2 = Situation id

                          WHEN 3 THEN 3

                          WHEN 4 THEN 12

                          ELSE Col2

             WHERE id IN (1, 2, 3, 4)

The next will update all rows in a single table

Update Table Set
Column1 = 'New Value'

The next will update all rows where the need for Column2 is much more than 5

Update Table Set
Column1 = 'New Value'
Column2 > 5

There's all Unkwntech's illustration of upgrading several table

UPDATE table1, table2 SET
table1.col1 = 'value',
table2.col1 = 'value'
table1.col3 = '567'
AND table2.col6='567'

You may even want to consider using joins on updates, that is possible too.

Update someTable Set someValue = 4 From someTable s Inner Join anotherTable a on s.id = a.id In which a.identification = 4
-- Only updates someValue in someTable that has an overseas key on anotherTable having a worth of 4.

Edit: When the values you're upgrading aren't originating from elsewhere within the database, you will need to problem multiple update queries.

Make use of a temporary table

// Reorder products

function update_products_tempdb(&lifier$products)


    $table_title = uniqid('tmp_test_')

    $sql = "CREATE TEMPORARY TABLE `$table_name` ("

        ."  `id` int(10) unsigned NOT NULL AUTO_INCREMENT"

        .", `position` int(10) unsigned NOT NULL"

        .", PRIMARY KEY (`id`)"

        .") ENGINE = MEMORY"


    $i =

    $sql = ''

    foreach ($products as &lifier$item)

    , )"


    if ($sql)

    Place INTO `$table_name` (id, position) VALUES $sql")

        $sql = "UPDATE `test`, `$table_name` SET `test`.position = `$table_name`.position"

            ." WHERE `$table_name`.id = `test`.id"



    query("DROP TABLE `$table_name`")

UPDATE table1, table2 SET table1.col1='value', table2.col1='value' WHERE table1.col3='567' AND table2.col6='567'

This will work with ya.

There's a reference in the MySQL manual for multiple tables.

I am unsure I realize. When you wish to update multiple rows, would you like to update all of them with similar value? for the reason that situation:

UPDATE mytable SET valueField = 'NewValue' WHERE idField IN (1,3,5,65,1584,1251)

or did you need to set multiple rows to various values?

UPDATE tableName SET col1='000' WHERE id='3' OR id='5'

This will achieve what you'r searching for. Just increase the id's. I've examined it.