7个回答
展开全部
你是指5张表的总记录还是相关的记录?
SELECT SUN(C) FROM (
SEELCT COUNT(*) C FROM TABLE1
UNION ALL
SEELCT COUNT(*) C FROM TABLE2
UNION ALL
SEELCT COUNT(*) C FROM TABLE3
UNION ALL
SEELCT COUNT(*) C FROM TABLE4
UNION ALL
SEELCT COUNT(*) C FROM TABLE5
);
或者:
SELECT COUNT(*) FROM TABLE1 A
INNER JOIN TABLE2 B ON A.ID=B.ID
INNER JOIN TABLE3 C ON C.ID=B.ID
INNER JOIN TABLE4 D ON D.ID=C.ID
INNER JOIN TABLE5 E ON E.ID=D.ID
SELECT SUN(C) FROM (
SEELCT COUNT(*) C FROM TABLE1
UNION ALL
SEELCT COUNT(*) C FROM TABLE2
UNION ALL
SEELCT COUNT(*) C FROM TABLE3
UNION ALL
SEELCT COUNT(*) C FROM TABLE4
UNION ALL
SEELCT COUNT(*) C FROM TABLE5
);
或者:
SELECT COUNT(*) FROM TABLE1 A
INNER JOIN TABLE2 B ON A.ID=B.ID
INNER JOIN TABLE3 C ON C.ID=B.ID
INNER JOIN TABLE4 D ON D.ID=C.ID
INNER JOIN TABLE5 E ON E.ID=D.ID
更多追问追答
追问
提示错误
Every derived table must have its own alias
SELECT SUN(C) FROM (select count(id) C from news UNION All select count(id) C from bbs)
追答
ORACLE 码?
展开全部
SELECT COUNT(COL) FROM
(
SELECT COL1 AS COL FROM TB1
)
UNION ALL
(
SELECT COL2 AS COL FROM TB2
)
WITH UR;
COL1和COL2最好是各自表的主键,你要查多个表的话在后面继续UNION ALL就行了,注意COL的名字要一样
(
SELECT COL1 AS COL FROM TB1
)
UNION ALL
(
SELECT COL2 AS COL FROM TB2
)
WITH UR;
COL1和COL2最好是各自表的主键,你要查多个表的话在后面继续UNION ALL就行了,注意COL的名字要一样
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
有2个方法:
1、select *,(select count(u_id) from h_travel_line where u_id = a.u_id) 已线路数
from h_travel a
2、SELECT c.ttt AS 已线路数, h_travel.*
FROM h_travel INNER JOIN
(SELECT COUNT(*) AS ttt, u_id
FROM h_travel_line
GROUP BY STID) c
ON h_travel.u_id =c.u_id
1、select *,(select count(u_id) from h_travel_line where u_id = a.u_id) 已线路数
from h_travel a
2、SELECT c.ttt AS 已线路数, h_travel.*
FROM h_travel INNER JOIN
(SELECT COUNT(*) AS ttt, u_id
FROM h_travel_line
GROUP BY STID) c
ON h_travel.u_id =c.u_id
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这样对吗:
SELECT SUm(C) FROM
(
select count(id) C from news
UNION All
select count(id) C from bbs
) a
SELECT SUm(C) FROM
(
select count(id) C from news
UNION All
select count(id) C from bbs
) a
更多追问追答
追问
FUNCTION data.SUN does not exist
追答
真晕,你写错了, 应该是sum,而不是sun
我给你改掉了,你也没有看见 ?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
问题描述的不够清晰!如果他们有关系的话,你把他们连接起来然后count就可以了啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询