1. 在做多表查询,或者查询的时候产生新的表的时候会出现这个错误:Every derived table must have its own alias(每一个派生出来的表都必须有一个自己的别名)。
select * from (select cust_num,count(cust_num) as countNum from b_phone_sale_extend_info where user_type = '促申完' group by cust_num) where countNum=2
当执行这条sql语句的时候就会出现Every derived table must have its own alias;
2. 原因是 mysql要求每一个派生出来的表都必须有一个自己的别名,那我给派生表加上别名即可;
修改后的sql,直接在新生产的表中加入他的别命名就行(“as a”或者“a”),“a”为新表的别名
select * from (select cust_num,count(cust_num) as countNum from b_phone_sale_extend_info where user_type = '促申完' group by cust_num)a
where countNum=2
这样就解决了问题;
版权声明:本文为LiZhen314原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。