Multiple Updates in MySQL

前端 未结 17 1308
南方客
南方客 2020-11-22 01:31

I know that you can insert multiple rows at once, is there a way to update multiple rows at once (as in, in one query) in MySQL?

Edit: For example I have the followi

17条回答
  •  渐次进展
    2020-11-22 01:40

    The following will update all rows in one table

    Update Table Set
    Column1 = 'New Value'
    

    The next one will update all rows where the value of Column2 is more than 5

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

    There is all Unkwntech's example of updating more than one table

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

提交回复
热议问题