
For an instructor lead, in-depth look at learning SQL click below.
Structured Query Language or SQL as it’s popularly known is the cornerstone of data analysis and manipulation in the realm of programming. Being proficient in SQL is indispensable in the current data-driven world. In this blog post, we will journey through the SQL fundamentals that will help build a strong base for more advanced concepts.
What is SQL?
SQL is a standard language for managing and manipulating databases. With SQL, one can create, read, update, delete or manipulate the data present in a database. SQL works primarily with relational databases, which organize data into tables.
SQL: The Basics
Before we dive into the actual coding, let’s warm up to some jargon. A database is a collection of related data. It is organized into tables. Each table has columns (fields) and rows (records).
SELECT Statement
The SELECT statement is used to select data from a database. The result is stored in a result table, sometimes called a result-set.
1 2 3 4 |
SELECT column1, column2, ... FROM table_name; |
Here, column1, column2, … are the field names of the table you want to select data from. If you want to select all fields available in a table, use * :
1 2 3 |
SELECT * FROM table_name; |
WHERE Clause
The WHERE clause is used to filter records and extract only those records that fulfill a specified condition.
1 2 3 4 5 |
SELECT column1, column2, ... FROM table_name WHERE condition; |
UPDATE Statement
The UPDATE statement is used to modify the existing records in a table.
1 2 3 4 5 |
UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition; |
DELETE Statement
The DELETE statement is used to delete existing records in a table.
1 2 3 |
DELETE FROM table_name WHERE condition; |
Remember, these form the barebones of SQL. As you progress, you will discover more complex functionalities but it’s all built upon these principles. SQL is a very powerful tool in the right hands and like any other language, the more you practice the better you get at it. So keep practicing!