Lesson 1: Getting data
In this section, we will learn to select (retrieve) data from a database table.
Note: For the sake of simplicity, we will assume that a database with tables has already been created. We will cover the process of creating databases and tables later in the course.
Now getting back to selecting data, suppose we have a Customers table like this:
customer_id
first_name
last_name
age
country
1
John
Doe
31
USA
2
Robert
Luna
22
USA
3
David
Robinson
22
UK
4
John
Reinhardt
25
UK
5
Betty
Doe
28
UAE
And, a marketing analyst wants to retrieve data on customer demographics (age and country) from the table.
We can achieve this by using the SQL SELECT statement, which we will explore next.
To perform this our query will look like this;
SELECT Age, Country
FROM Customers;
The Query Result;
Age
Country
31
USA
22
USA
22
UK
25
UK
28
UAE
Last updated