Saturday 18 May 2019

Postgres: Get the data from table


Using SELECT statement, you can get the data from table.

SELECT * FROM employee;
Above statement return all the records from table employee;
myOrg=# SELECT * FROM employee;
 id |     name     
----+--------------
  1 | Hari Krishna
  2 | Gopi
  3 | Sudhir
(3 rows)


You can also specify a specific field to display.

myOrg=# SELECT name FROM employee;
     name     
--------------
 Hari Krishna
 Gopi
 Sudhir
(3 rows)


You can query for multiple fields at a time.

myOrg=# SELECT name, id FROM employee;
     name     | id 
--------------+----
 Hari Krishna |  1
 Gopi         |  2
 Sudhir       |  3
(3 rows)




Previous                                                 Next                                                 Home

No comments:

Post a Comment