Using SQL
SQL code is written as a series of statements. Later in the text, Chapter 5 and Chapter 6 cover statements like CREATE
for defining new tables and INSERT
for adding data. In this part, Chapter 3 covers SELECT
statements, which are arguably the most useful statements for data scientists. SELECT
statements are also called queries because they query table(s), with particular characteristics, from databases.
A query is made up of clauses. Every query must have a SELECT
and FROM
clause. Other clauses include WHERE
, GROUP BY
, HAVING
, and ORDER BY
, all of which will be covered in Chapter 3.
Because of the efficiency of data storage in SQL databases, it is often necessary to combine information held across two or more tables. Chapter 4 covers combining tables via JOIN
(combining columns) and via UNION
(combining rows).