SQL Tutorial 1 : “SELECT FROM WHERE” Framework


The key framework governing SQL are these 3 keywords : “SELECT”, “FROM”,  “WHERE”.

Firstly, for SELECT, we are choosing which columns in the database that we want to extract data from.

Secondly, for FROM, we are choosing which table in the database to extract data from. This is crucial because a database can consist of many different tables. For instance, a logistics company could have a table with buyer’s data and a separate table with seller’s data. You can think of it as a database consisting of many excel files, and this step requires you to narrow down which specific excel file to extract data from. Another way to see this is the table which consists of the column you have selected in the “SELECT” step of your query.

Thirdly, for WHERE, we are setting criterias to filter data. This is crucial because if we extract data without any filters, the file size could be extremely huge. Also, the data that we extract will be mostly made up of data which we do not need. Hence, we apply the WHERE function to get only the specific data that we require. This makes our dataset more meaningful.

This can be seen from the example below, a dataset named world_data with data of 5 countries.

(In reality, databases are much more complex than this but we will use this for illustrative purposes)

(Assume that this table name is ”world_data”)

If we want to extract the population data of Albania only,

we will write the following query :

SELECT population

FROM world_data

WHERE name = “Albania”

The output will be:

Also, do note that the output can be obtained in various forms, such as in csv or excel files.

Next : SQL Tutorial 2 : Additional criterias with the use of OR/IN/AND Functions

One thought on “SQL Tutorial 1 : “SELECT FROM WHERE” Framework

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s