Every derived table must have its own alias

青旅半醒 2024-04-01 09:18 202阅读 0赞
  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;

fbe3617a687144a0ae9e1811a461598b.png

  1. 原因是 mysql要求每一个派生出来的表都必须有一个自己的别名,那我给派生表加上别名即可;

修改后的sql,直接在新生产的表中加入他的别命名就行(“as a”或者“a”),“a”为新表的别名

  1. select * from (select cust_num,count(cust_num) as countNum from b_phone_sale_extend_info where user_type = '促申完' group by cust_num)a
  2. where countNum=2

这样就解决了问题;

发表评论

表情:
评论列表 (有 0 条评论,202人围观)

还没有评论,来说两句吧...

相关阅读