Home > Blockchain >  How can we print 2 tables with all columns in psql using single query?
How can we print 2 tables with all columns in psql using single query?

Time:05-25

We SELECT data from multiple tables in mysql or SQL Server with SELECT * FROM table1, table2;.

But in pgAdmin this query does not work like it should be.

Can anyone tell me how can I get my desired output with this or there's any mistake in this logic?

CodePudding user response:

assuming both tables have the same number of columns (and preferably the columns are ordered and labelled similarly...)

select * from table1
union all
select * from table2
  • Related