Mysql-经典语句收集

一、求两个日期间的天数sql

-- fucarry中一条记录有两个合约,求该条记录这两个合约到期日的相差天数
select a.futu_code,
      datediff((select expire_date 
         from hs_user.ptfutucode b where a.exchange_type = b.exchange_type
          and a.futu_code = b.futu_code),(select expire_date 
         from hs_user.ptfutucode b where a.exchange_type = b.exchange_type
          and a.second_code = b.futu_code)) as diff_date
 from hs_futu.fucarry a;

一、delete中的子查询(删除tableA中)code

delete a
  from tableA a, tableB b
 where a.column = b.column;
相关文章
相关标签/搜索