Mysql判断表是否存在并删除,将查询结果插入到新表,查询并创建新表

drop  table if exists sys_audit_temp;

create TABLE sys_audit_temp  as  (select type1.sum as sum1,type2.sum as sum2,type3.sum as sum3,type4.sum as sum4,type5.sum as sum5 from

(SELECT count(*) as sum FROM sys_audit as a where  OWNERMODEL='业务管理') as type1,

(SELECT count(*) as sum FROM sys_audit as a where  OWNERMODEL='用户管理' or OWNERMODEL='担保公司管理' ) as type2,

(SELECT count(*) as sum FROM sys_audit as a where  OWNERMODEL='登录管理') as type3,

(SELECT count(*) as sum FROM sys_audit as a where  OWNERMODEL='系统配置') as type4,

(SELECT count(*) as sum FROM sys_audit as a where  OWNERMODEL='末指定' or OWNERMODEL='贷款产品') as type5)

你可能感兴趣的:(Mysql判断表是否存在并删除,将查询结果插入到新表,查询并创建新表)