In this quick guide, we will be looking at the simply command structure/syntax of SQL – DQL.
SQL – Stands for Structured Query Language. It is a language that is used to communicate with a database.
DQL– Data Query Language aspect of MySQL.
As an Data Scientist or aspiring one, you will be interacting with lots of databases and SQL will be in the way.
A simple way to remember the simple query structure/syntax of DQL is:
SELECT
FROM
WHERE
GROUP (BY)
HAVING
ORDER (BY) ;
The First 2 KEYWORDS – that is SELECT and FROM are required. The others are optional.
Hence you get:
SELECT the data you want
FROM these database and tables
WHERE these criteria are met
GROUP (BY) this field
HAVING this property
ORDER (BY) this field or list ;
These keywords are not case sensitive, but it is always a good practice to distinguish them from other words by capitalising them.
And also though you can write them as one full English sentence it is always a good practice to start EACH KEYWORD on a new line.