We help IT Professionals succeed at work.

Join multiple sql in postgresql

Newton
Newton asked
on
Medium Priority
47 Views
Last Modified: 2020-03-03
I have below 3 sql but I need 1 sql that can show all 3 result as 1 output

Sql : select current_database();
Output : dbname

Sql : select inet_server_addr();
Output : 101.99.234.20

Sql : select user;
Output : userA

Above is 3 different output but I need 1 sql that can give 1 output like below.

Output
Current_database,ip,user
Dbname, 101.99.234.20, userA

Is it possible to join these sql.
Comment
Watch Question

Software Tead Lead / Business Analyst / System Analyst / Data Engineer
CERTIFIED EXPERT
Commented:
try like:

select current_database(), inet_server_addr(), user 

Open in new window

strivoliIT Manager
CERTIFIED EXPERT

Commented:
Create a VIEW that "collects" data from the 3 Tables.
Peter ChanProblem resolver

Commented:
Use Union all to combine all 3 queries.

Author

Commented:
Thank You Ryan. My problem solved.