DEV Community

Agu O. Wisdom
Agu O. Wisdom

Posted on

PostgreSQL SELECT STATEMENT.

How to use the PostgreSQL SELECT statement.

In this short tutorial, you are going to learn how to use the Postgres SELECT statement to query the database and retrieve information from a table.

The Postgres SELECT statement is one of the most used queries in SQL, it is used to retrieve data from tables. It is part of the queries used to perform CRUD (Create, Read, Update, Delete) operations in SQL. The SELECT statement is the READ in the CRUD operations, since it is used to read or retrieve data.

Let's see an example of how to use SELECT.
The following shows an example on how to use SELECT:

SELECT list_name FROM table_name;
Enter fullscreen mode Exit fullscreen mode

Now, let's break it down:

  • First, specify a list, can be a column or list of columns from the table you want to query.

  • Ensure that the data you want to retrieve exists in the table.

  • If you are selecting multiple columns, you need to use comma , after each column name.

  • Use the asterisk * shorthand to retrieve all the columns from a table (not a good practice).

  • The FROM clause specifies the table you want to select from.

  • And finally, the table name, which is the name of the table you want to select from.

NOTE: In PostgreSQL, the semicolon at the end of the table name is not optional. If you skip the semicolon, Postgres will throw an error.

Conclusion: In this short tutorial, you have learned how to use the PostgreSQL SELECT to query a database and retrieve information from a table.

Top comments (0)

Tiugo image

Fast, Lean, and Fully Extensible

CKEditor 5 is built for developers who value flexibility and speed. Pick the features that matter, drop the ones that don’t and enjoy a high-performance WYSIWYG that fits into your workflow

Start now

👋 Kindness is contagious

Dive into this thoughtful article, cherished within the supportive DEV Community. Coders of every background are encouraged to share and grow our collective expertise.

A genuine "thank you" can brighten someone’s day—drop your appreciation in the comments below!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found value here? A quick thank you to the author makes a big difference.

Okay