How to Use SELECT and FROM clause

Chinaza MaryTheresa Akwue

By Chinaza MaryTheresa Akwue

Nov 27

Introduction

Understanding the SELECT and FROM clauses is crucial in the world of databases. They are foundational SQL commands that allow us to retrieve specific data from tables, which will empower you to make informed decisions.

Imagine a treasure chest filled with valuable data, and the SELECT and FROM clauses are the keys to unlocking it. Whether you're analyzing business metrics, exploring datasets, or building applications, understanding these clauses is important.

This article lays the foundation for future SQL competency by guiding you through the use of SELECT and FROM in PostgreSQL pgAdmin with examples. PostgreSQL was utilised to illustrate a few examples for this article.

Overview of PostgreSQL pgAdmin

A popular open-source graphical user interface (GUI) tool for PostgreSQL database administration is called pgAdmin.With its user-friendly interface in pgAdmin, PostgreSQL is a robust open-source database that makes data querying simple, even for beginners. For database administrators, developers, and analysts, pgAdmin offers a simple user interface for interacting with PostgreSQL servers.


For guidance on How to install Postgresql and pgAdmin on your PC, click here!

The SELECT Clause

The primary purpose of the SELECT clause is to specify the column you want to retrieve from a database. It allows you to query specific columns or perform operations on data, making it the foundation of most SQL queries.

When you execute a query using the SELECT clause, the database returns a result set containing the requested data, which can range from a single column to multiple columns.



The FROM Clause

The FROM clause is a critical component of an SQL query, used to specify the table or tables from which data is pulled. It follows the SELECT clause and serves as the starting point for accessing the database's structure. By identifying the table, the FROM clause defines the source of the columns and rows used in the query

Without the FROM clause, the query would lack context for where to retrieve the requested information.

Practical example of a basic Select query:


Below is a practical example in how to write a query using the SELECT and FROM clause

The column_name from the above image refers to the specific field(s) in the table that you want to retrieve, and table_name is the name of the table from which the data is being selected.


Methods of retrieving data using the SELECT clause.

There are two methods of retrieving data using the select clause:

  • The SELECT *
  • The SELECT columns


The SELECT *:

Here you are to select all columns from a table.

Let's assume you have a table named ”film” with columns “film_id,” “title,” “description,” “rating,” and "release_year." To retrieve all data from this table, you can write:

This query instructs PostgreSQL to Select all columns (*) from the film table.

After writing your query, click on the play icon to Run your query, or you can use the keyboard shortcut “F5” or “Shift + F5” or “Fn (function key) + F5” depending on your laptop keyboard.


The SELECT column(s):

Here you are to select specific column(s) from your dataset.

To retrieve only specific columns, list them after the SELECT keyboard.


From the previous example, suppose you want to select specific columns and not all columns in the film table.

Example:

You want to retrieve data on the film_id, title, release_year, and rating from the film table.

You can write the query below and then run the query to get a result.

Notice that the result set was displayed in the Data Output section.

Conclusions

By mastering the SELECT and FROM clauses, you can unlock the power of your PostgreSQL database. With practice and experimentation, you'll be able to craft complex queries to extract valuable insights from your data. Remember, the journey of data exploration begins with a simple SELECT and FROM.

Are you looking to learn more about SQL as a beginner, or do you want to polish your SQL skills for the future of work? Join our next Data Analytics Bootcamp!


Table of contents
  1. Introduction
  2. Overview of PostgreSQL pgAdmin
  3. The SELECT Clause
  4. The FROM Clause
    1. Practical example of a basic Select query:
    2. Methods of retrieving data using the SELECT clause.
      1. The SELECT *:
      2. The SELECT column(s):
  5. Conclusions
resa logo

Empowering individuals and businesses with the tools to harness data, drive innovation, and achieve excellence in a digital world.

Copyright 2025Resagratia. All Rights Reserved.