sqlsql-likeclickhouseredash

Trying to all rows from 4 different tables, Clickhouse doesnt detect table when using union all


So I have 4 subtables all the same schema and I want to show all rows between all the tables so I can have redash convert it into a chart

My current idea was to just have chain of union all, but for some reason, clickhouse doesnt think it exists

select * from first 
union all
select * from second 

results in: "Exception: Table second doesn't exist"

However

select * from second

works just fine.

is there something that I am missing from this logic?


Solution

  • I figured it out, for some reason I had to select from the union of selects

    select * from (
    select * from first
    union all
    select * from second
    ...
    ) group by ...
    

    I don't know why it doesn't detect the table with my original method, but it worked out now

    I hope someone with a similar issue will find this helpful