I would like to write a single HQL query that return a specific count from 4 tables in different columns.
I have 4 tables: Tab1
, Tab2
, Tab3
and Tab4
, and I would like to get something like this:
|Tab1 | Tab2 | Tab3 | Tab4 |
|..1....|..13...|...7...|....0...|
All records in Tab#
s have their own id
and ObjectID
and ObjectFetch
columns
I have tried something like this:
select DISTINCT
(select count(*) from Tab1 where ObjectFetch=:fetch and ObjectID=:id),
(select count(*) from Tab2 where ObjectFetch=:fetch and ObjectID=:id),
(select count(*) from Tab3 where ObjectFetch=:fetch and ObjectID=:id),
(select count(*) from Tab4 where ObjectFetch=:fetch and ObjectID=:id),
from Tab1, Tab2, Tab3, Tab4
But it doesn't work at all, any idea why?