CREATEFUNCTION `F_Ip2Int`(ip varchar(15)) RETURNSbigint(20) BEGIN declare tmp bigintdefault0; while instr(ip,'.')>0 do set tmp = tmp*256+left(ip,instr(ip,'.')-1); set ip =right(ip,length(ip)-instr(ip,'.')); endwhile; set tmp = tmp*256+ip; return tmp; END
把bigint转换成IP地址
CREATEFUNCTION `F_Int2Ip`(iip bigint) RETURNSvarchar(15) BEGIN return concat((iip &0xFF000000)>>24, '.', (iip &0x00FF0000)>>16, '.', (iip &0x0000FF00)>>8, '.', iip &0x000000FF); END