PostgreSQL SELECT Query
To extract data from a database, you need to use the PostgreSQL SELECT statement.The PostgreSQL Select statement is used to select or fetch data from the database table.The data return from the database table as the result table is also known as the result-set.
SELECT Syntax :
The SELECT statement is the most complex statement and can be combined with other clauses to form a powerful query.The syntax of the SELECT statement is −
SELECT column1, column2, columnN FROM table-name;
column1 , column2, column3: names of the fields of the table
table-name: table where we want to fetch data.
If we want to select all the columns from the respective table then we use the following syntax:
SELECT * FROM table-name;
SELECT Example :
Consider the STUDENT table is having the following records
The following is an example, which would fetch ID and NAME record for a STUDENT.
lfcdb=# SELECT ID, NAME FROM STUDENT ;
All the above statements would create the following records in STUDENT table