boss给妹子出了道小题,没事给她解了:
update test_123 as a
inner join (SELECT pid,COUNT(sons) count FROM test_123 GROUP BY pid ) as b on a.id = b.pid
set a.sons = b.count;
顺便还查了查update里插if 和 case的语法,有意思
boss给妹子出了道小题,没事给她解了:
update test_123 as a
inner join (SELECT pid,COUNT(sons) count FROM test_123 GROUP BY pid ) as b on a.id = b.pid
set a.sons = b.count;
顺便还查了查update里插if 和 case的语法,有意思
转载于:https://www.cnblogs.com/JohannaFeng/p/5776409.html