依靠连接表 [英] Count on a table with joins

查看:73
本文介绍了依靠连接表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个表的列上执行计数功能,在该列上我还执行了与其他表的多次联接.
我面临的问题是,计数是在完全联接的结果上执行的,在我的情况下,我希望在特定的表上执行计数.我应该如何解决这个问题? /div>

只需在查询中返回其他值.
从性能的角度来看,我认为这不是最好的方法,但是它应该可以工作.

选择*,(从tab1中选择count(*)),从tab1,tab2,tab3中,其中tab1.a = tab2.a和.......


您可以完全使用单独的选择语句.


I want to perform a count function on a column of a table where i have also performed multiples joins with other tables.
The problem i''m facing is that the count was performed on the result of the complete joins where in my case i want it to performed on that particular table.How should i solved this

解决方案

Just return additional values in your query.
I dont think this is the best way from a performance perspective, but it should work.

select *, (select count(*) from tab1) from tab1, tab2, tab3 where tab1.a = tab2.a and.......


You could use a completely separate select statement for it.


这篇关于依靠连接表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆