Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

PostgreSQL UNION

PostgreSQL UNION clause/operator is used to combine the results of two or more SELECT statements without returning any duplicate rows
postgres=# select * from tab1;     postgres=# select * from tab2;
 id | name                              id |  name  
----+-------                           ----+--------
  1 | nijam                              1 | jamal
  2 | abu                                2 | smith
  3 | umar                               4 | daniel
  7 | jamal                              5 | zaheer
(4 rows)                               (4 rows)
-- From above table  tab1 and tab2 having one duplicate values "name=jamal" is duplicate so union clause shows only one rows of tab1 table (7,jamal), table tab2 duplicate row will not show 
postgres=# select name from tab1 union select name from tab2;    
  name  
--------
 smith
 daniel
 zaheer
 nijam
 abu
 jamal
 umar
(7 rows)











Comments

Popular posts from this blog

Script to find sessions that are blocking other sessions in PostgreSQL

How to find the server is whether standby (slave) or primary(master) in Postgresql replication ?

How to Get Table Size, Database Size, Indexes Size, schema Size, Tablespace Size, column Size in PostgreSQL Database

PostgreSQL pgBadger

How to Return a Result Set from a PostgreSQL Stored Procedure