1.mysql 中分解IP的查询语句:
select substring_index(substring_index(y.ip, '.',1), '.', -1) a,
substring_index(substring_index(y.ip, '.',2), '.', -1) b,
substring_index(substring_index(y.ip, '.',3), '.', -1) c,
substring_index(substring_index(y.ip, '.',4), '.', -1) d
from (select '127.0.0.1' as ip from t1)y
2. 找到包含最大值和最小值的记录
select ename
from emp
where sal in((select min(sal) from emp),
(select max(sal) from emp));