MySQL update join with limit

后端 未结 3 2132
长情又很酷
长情又很酷 2021-02-15 06:05

I would like to know how to update a table, with values from another table, by the trick is I need to set a limit because I have thousands of rows to update, and PHPmyadmin can\

3条回答
  •  鱼传尺愫
    2021-02-15 06:44

    sqlFiddle in this example I am only doing 5 rows, you can change the limit to 0,100 if you'd like

    UPDATE wp_postmeta,
          (SELECT oldmap,newmap
           FROM wp_map 
           ORDER BY oldmap,newmap limit 0,5)as wp_map
    SET wp_postmeta.meta_value = wp_map.newmap
    WHERE wp_map.oldmap = wp_postmeta.meta_value
    

提交回复
热议问题