You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Structured Query Language (SQL) is the standard language for interacting with relational databases. SQL allows you to retrieve, insert, update, and delete data. This lesson covers the most fundamental retrieval operations.
The SELECT statement retrieves data from one or more tables.
SELECT column1, column2, ...
FROM table_name;
SELECT *
FROM Students;
The asterisk (*) selects every column. In production code, it is better to name specific columns for clarity and efficiency.
SELECT FirstName, Surname, DateOfBirth
FROM Students;
This returns only the three named columns.
You can rename columns in the output using AS:
SELECT FirstName AS "First Name", Surname AS "Last Name"
FROM Students;
To remove duplicate rows from the results:
SELECT DISTINCT FormGroup
FROM Students;
This returns each unique form group only once.
The WHERE clause filters rows based on a condition. Only rows that satisfy the condition are returned.
SELECT column1, column2
FROM table_name
WHERE condition;
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.