Skip to content
MySQL Crash Course
MySQL Crash Course

icon picker
03-Selecting Data

Structured Query Language

The programming language used to interact with the MySQL database is called the structured query language or SQL for short.
The language is divided into two types of commands or functions. The first being the data definition language (DDL) that is used to define the structure of the database and it's tables and relations between them. DDL is also used to describe how each table is going to store data inside of it.
The second part is the data manipulation language (DML). It is used to store, retrieve, and manipulate the data stored in the tables.
The command the we use to modify the database or it's tables or retrieve data from them is known as a query.
The SELECT command is the most used command in SQL as it is used to retrieve data from the database. Different clauses can be added to it in order to modify the results that you receive from the database.
The most commonly used clause is the asterisk sign, it's a wildcard character and will return all of the data that the table contains.
If you want data only from specific records where a certain value exists and not return the whole table then you can use the WHERE clause.
SELECT name, email FROM users WHERE country = 'Kenya'
You can also use the `Order by` clause and define if you want the numerical records to be presented in a ascending order or a descending order.
SELECT name, email, salary FROM employees ORDER BY DESC
If you want to remove results where a column has a null value or you need to retrieve data where a column has null values you can use the IS NOT NULL and IS NULL clauses respectively.
SELECT name, email FROM users WHERE email IS NOT NULL
SELECT name, email FROM users WHERE email IS NULL

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
) instead.