Java DB,如何计算 Union 中的行数 select
Java DB, How to count row in Union select
我想知道如何计算这个 select Java 数据库中联合的行数
Select R.ID , R.CAPACITE from ASSISTE A
join REPRESENTATION R on R.ID = A.IDREPRESENTATION
where R.ID = 7
union all
SELECT R.id ,R.CAPACITE FROM BILLET B
join REPRESENTATION R on R.ID = B.IDREPRESENTATION
where R.ID = 7
我试过
Select count(*) from (Select R.ID , R.CAPACITE from ASSISTE A
join REPRESENTATION R on R.ID = A.IDREPRESENTATION
where R.ID = 7
union all
SELECT R.id ,R.CAPACITE FROM BILLET B
join REPRESENTATION R on R.ID = B.IDREPRESENTATION
where R.ID = 7 )
但是我收到了这个错误!
Error code 30000, SQL state 42X01: Erreur de syntaxe : Encountered "<EOF>" at line 7, column 21.
Line 2, column 1
请帮忙 :D
我想你忘了在最后添加别名。尝试这样的事情:
Select count(*) from (
Select R.ID , R.CAPACITE from ASSISTE A
join REPRESENTATION R on R.ID = A.IDREPRESENTATION
where R.ID = 7
union all
SELECT R.id ,R.CAPACITE FROM BILLET B
join REPRESENTATION R on R.ID = B.IDREPRESENTATION
where R.ID = 7
) A
我想知道如何计算这个 select Java 数据库中联合的行数
Select R.ID , R.CAPACITE from ASSISTE A
join REPRESENTATION R on R.ID = A.IDREPRESENTATION
where R.ID = 7
union all
SELECT R.id ,R.CAPACITE FROM BILLET B
join REPRESENTATION R on R.ID = B.IDREPRESENTATION
where R.ID = 7
我试过
Select count(*) from (Select R.ID , R.CAPACITE from ASSISTE A
join REPRESENTATION R on R.ID = A.IDREPRESENTATION
where R.ID = 7
union all
SELECT R.id ,R.CAPACITE FROM BILLET B
join REPRESENTATION R on R.ID = B.IDREPRESENTATION
where R.ID = 7 )
但是我收到了这个错误!
Error code 30000, SQL state 42X01: Erreur de syntaxe : Encountered "<EOF>" at line 7, column 21.
Line 2, column 1
请帮忙 :D
我想你忘了在最后添加别名。尝试这样的事情:
Select count(*) from (
Select R.ID , R.CAPACITE from ASSISTE A
join REPRESENTATION R on R.ID = A.IDREPRESENTATION
where R.ID = 7
union all
SELECT R.id ,R.CAPACITE FROM BILLET B
join REPRESENTATION R on R.ID = B.IDREPRESENTATION
where R.ID = 7
) A