企业微信截图_16255606508145.png

    1.更改某个字段的某个值的前几位数改为期望的值
    update Device set name = replace(name,”410922”,”240802”) where farmId =410922 ;

    2.在更改id时可以更改id就是那个id的sql记录,所以执行方式是先找到记录再更改。
    update Device set farmID = 240802 where farmId =410922 ;

    3.更改ip的语句

    image.png

    update Device set ipAddress = replace(ipAddress,”192.169.1.1”,”192.168.145.1”) where farmID =240802;

    update Device set ipAddress = replace(ipAddress,”192.168.145.1”,”192.168.145.201”) where id =240802001; update Device set ipAddress = replace(ipAddress,”192.168.145.2”,”192.168.145.202”) where id =240802002 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.3”,”192.168.145.203”) where id =240802003 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.4”,”192.168.145.204”) where id =240802004 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.5”,”192.168.145.205”) where id =240802005 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.6”,”192.168.145.206”) where id =240802006;
    update Device set ipAddress = replace(ipAddress,”192.168.145.7”,”192.168.145.207”) where id =240802007 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.8”,”192.168.145.208”) where id =240802008 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.9”,”192.168.145.209”) where id =240802009 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.10”,”192.168.145.210”) where id =240802010 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.11”,”192.168.145.211”) where id =240802011 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.12”,”192.168.145.212”) where id =240802012 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.13”,”192.168.145.213”) where id =240802013 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.14”,”192.168.145.214”) where id =240802014 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.15”,”192.168.145.215”) where id =240802015 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.16”,”192.168.145.216”) where id =240802016 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.17”,”192.168.145.217”) where id =240802017 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.18”,”192.168.145.218”) where id =240802018;
    update Device set ipAddress = replace(ipAddress,”192.168.145.19”,”192.168.145.219”) where id =240802019 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.20”,”192.168.145.220”) where id =240802020 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.21”,”192.168.145.221”) where id =240802021 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.22”,”192.168.145.222”) where id =240802022 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.23”,”192.168.145.223”) where id =240802023 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.24”,”192.168.145.224”) where id =240802024 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.25”,”192.168.145.225”) where id =240802025 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.26”,”192.168.145.226”) where id =240802026 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.27”,”192.168.145.227”) where id =240802027 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.28”,”192.168.145.228”) where id =240802028 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.29”,”192.168.145.229”) where id =240802029 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.30”,”192.168.145.230”) where id =240802030 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.31”,”192.168.145.231”) where id =240802031 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.32”,”192.168.145.232”) where id =240802032 ;
    update Device set ipAddress = replace(ipAddress,”192.168.145.33”,”192.168.145.233”) where id =240802033 ;