
复制lock tables `categories` write,表别名
`categories` as `c1` write, `categories` as `c2` write; update `categories` as `c1`, `categories` as `c2` set `c1`.`parent_id` = `c2`.`parent_id` where `c1`.`parent_id` = `c2`.`cat_id` and `c2`.`cat_id` = $cat_id; delete from `categories` where `cat_id` = $cat_id; unlock tables; 1.2.3.4.5.6.7.8.