MYSQL将查询结果插入新表

select count(*) from custinfo -- 101568
select count(*) from custinfo where length(trim(custinfo.`账号`))=23 -- 101233
select count(*) from custinfo where length(trim(custinfo.`账号`))=19 -- 335
select 101233+335

---------------------------------------------------------

select count(*) from custinfo where length(trim(custinfo.`账号`))<>19 and length(trim(custinfo.`账号`))<>23

create table temp23 as select * from custinfo where length(custinfo.`账号`)=23
create table temp19 as select * from custinfo where length(custinfo.`账号`)=19

select count(*) from temp23
select count(*) from temp19

---------------------------------------------------------------------
select temp23.*, private_accountinfo202006.`余额` from temp23 left join private_accountinfo202006 on temp23.`账号` = private_accountinfo202006.`账号`
union
select temp19.*, private_accountinfo202006.`余额` from temp19 left join private_accountinfo202006 on temp19.`账号` = private_accountinfo202006.`银行卡`

 

posted @ 2020-07-10 09:15  n0page404  阅读(150)  评论(0)    收藏  举报