mysql/常用函数

常用函数

1。oracle/decode()函数 & mysql /case when .. then ..else..end函数

(1)oracle处理返回结果:如处理ischeck值,值为2时,设置该值为0,否则为ischeck本身。

      select decode(ischeck,2,0,ischeck) from tb;//处理ischeck的值,值为2时指定新值0,否则输出原值ischeck

(2)mysql处理

     select case when ischeck='2' then '0' else ischeck end from tb;

2。mysql分组取最新一条数据

select max(id),name from db group by name

原文地址:https://www.cnblogs.com/kaixinyufeng/p/10007975.html