DISCLAIMER: ANSI SQL (The SQL that's used universally) includes everything taught in this section. However, some of the syntax shown will vary between your Relational Database Management Service (RDBMS).
Also, this section is intended for individuals who have at least a basic knowledge of how relational databases work.
SELECT statements are the most common statements in SQL and are used to execute queries on
tables and views (we cover those in a later tutorial). To get started with SELECT statements, we'll cover the
following learning objectives:
SELECT *
FROM [table_name];
SELECT COUNT(*)
FROM [table_name];
SELECT [col1], [col2], [col3], [col4]
FROM [table_name];
WHERE
clause with the following syntax:
SELECT *
FROM [table_name]
WHERE [condition(s)];
AND
and/or OR
keywords with the following syntax:
SELECT *
FROM [table_name]
WHERE [condition1] [AND/OR] [condition2];
ORDER BY
clause with the following syntax: SELECT *
FROM [table_name]
ORDER BY [column1];
ORDER BY
clause, in conjunction with the DESC
keyword, with the following syntax: SELECT *
FROM [table_name]
ORDER BY [column1] DESC;
LIMIT
keyword, followed by the number of rows to return, with the following syntax: SELECT *
FROM [table_name]
ORDER BY [column1]
LIMIT [num_rows];
Congratulations! You just completed the Intro to SQL Statements Tutorial! To help test your knowledge, let's use
the database you populated in the previous tutorial to run some basic queries. This exercise is based on the exercise of
the previous tutorial.
**It's highly recommended that you
complete the exercise outlined in the previous tutorial before beginning this exercise.**
Have any issues with the above exercise? Post your question on Discord!