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了…