MySQL联表统计查询报错“Every derived table must have its own alias”

MySQL联表统计查询报错 Every derived table must have its own alias

意思就是派生表需要加个别名,参照我的原SQL

select * from
  (select
      count(pid) as msum,
      count(sex = '男' or null ) as mman,
      count(sex = '女' or null ) as mwoman
    from myc_member),
  (select
      count(pid) as psum,
      count(sex = '男' or null ) as pman,
      count(sex = '女' or null ) as pwoman
    from myc_partymember)

这就报错了,给个名字后

select * from
  (select
      count(pid) as msum,
      count(sex = '男' or null ) as mman,
      count(sex = '女' or null ) as mwoman
    from myc_member) as one,
  (select
      count(pid) as psum,
      count(sex = '男' or null ) as pman,
      count(sex = '女' or null ) as pwoman
    from myc_partymember) as tow

OK了…

发布了104 篇原创文章 · 获赞 264 · 访问量 54万+

猜你喜欢

转载自blog.csdn.net/teavamc/article/details/86709542
今日推荐