你的目的是找c表中能在a表找到对应值记录的数量找d表中能在a表找到对应值记录的数量
但是你最后一句的涵义是a表中能在d表和c表同时找到对应值的数量,此时count(c.p_rel_id)其实是你c表的数量,就是那个504的涵义,至于count(d.p_rel_id)为什么等于504 完全是凑巧~~~
select sum(cnt) from(
select count(*) as cnt from tb_one where title like '%蜡笔小新%'
union all
select count(*) as cnt from tb_two where title like '%蜡笔小新%'
union all
select count(*) as cnt from tb_three where title like '%蜡笔小新%') t
这样不就可以么?
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)