Chinaunix
标题:
再多表中统计记录数的关系?
[打印本页]
作者:
soulofrain
时间:
2003-02-28 11:58
标题:
再多表中统计记录数的关系?
再多表中统计记录数的关系?
比如现在有两个表table_a和table_b,我想在这两个表中统计符合条件con_a和con_b的记录数,con_a是table_a的
条件,con_b是table_b的条件,这两个表没有任何联系。
如何我
count(*)
into $i_a
from table_a
where con_a;
count(*)
into $i_b
from table_b
where con_b;
i_a + i_b就是我想要的结果,我如何通过一条语句实现呢?
例如:
count(*)
into $i_sum
from table_a, table_b
where .............
我不知道where应该如何写?是con_a and con_b呢还是con_a or con_b呢?
如何按照笛卡儿应该时and的关系,但是结果好像不对?
谢谢!
作者:
suwk
时间:
2003-03-01 13:59
标题:
再多表中统计记录数的关系?
select (select count(*) from a_table)+count(*) from b_table
作者:
chinawhd
时间:
2003-03-01 15:23
标题:
再多表中统计记录数的关系?
楼上的正确!
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2