mysql常用函数

日期格式化:
date_format(now(),'%Y-%c-%d %h:%i:%s')


update t_oa_wjmlxx t1 inner join t_oa_wjccxx t2  on t1.mlxxid=t2.parentid and t2.wjccxxid in ('2c90d8c35003b7eb015004187a0f0013') set t1.xgsj=now(), t1.xgr='admin'

select t.bh,
       t.clsj,
       t.dm,
       t.fjdz,
       t.isshpt,
       t.jlnf,
       t.lyzt,
       t.nr,
       t.sldw,
       t.title,
       date_format(t.tjsj, '%Y-%m-%d') as tjsj,
       t.tjzsf,
       t.twzxm,
       d.name,
       z.zdmc as ztmc,
       (select case
                 when t.lyzt = '00007' then
                  'green.jpg'
                 else
                  s.tblj
               end) as tblj
  from t_ygfw_message t
  left join t_ygfw_dept d
    on t.sldw = d.dm
  left join sjzd z
    on t.lyzt = z.zddm
  left join t_ygfw_sjdcsb s
    on (unix_timestamp(now()) - unix_timestamp(t.tjsj)) / (60 * 60 * 24) + 0.5 >=
       s.mintime
   and (unix_timestamp(now()) - unix_timestamp(t.tjsj)) / (60 * 60 * 24) + 0.5 <
       s.maxtime
 where 1 = 1
 order by t.tjsj desc, t.bh asc

相关推荐