
For an instructor lead, in-depth look at learning SQL click below.
Structured Query Language (SQL) is a versatile programming language designed specifically for querying and managing data in relational databases. When you learn SQL, you gain the ability to interact directly with your data, retrieving specific information, manipulating the data, and generating complex reports.
SQL Basics
SQL, at its core, is about performing operations on data. There are four basic operations, or “CRUD” operations: Create, Read, Update, and Delete. Let’s take a look at some examples of these commands:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
--Creating a table CREATE TABLE Employees ( ID int, Name varchar(255), Age int, Address varchar(255), Salary int ); --Inserting data into the table INSERT INTO Employees (ID, Name, Age, Address, Salary) VALUES (1, 'John', 32, '10 Downing St', 3000); --Updating data in the table UPDATE Employees SET Salary = 3200 WHERE ID = 1; --Deleting data from the table DELETE FROM Employees WHERE ID = 1; |
Exploring Different Databases
SQL code works on numerous types of databases. Here are a few popular types of databases where you will find SQL very useful:
MySQL
MySQL is the most popular database system used with PHP and a critical component of the LAMP stack (Linux, Apache, MySQL, PHP/Python/Perl). Here’s an example of a simple SELECT statement to retrieve records from a MySQL database table:
|
1 2 3 4 |
SELECT * FROM Employees WHERE Salary > 2000; |
PostgreSQL
PostgreSQL is an open-source relational database system that is known for its extensibility and standards-compliance. An example of a SELECT statement to retrieve records from a PostgreSQL database table would be identical to MySQL:
|
1 2 3 4 |
SELECT * FROM Employees WHERE Salary > 2000; |
Microsoft SQL Server (MSSQL)
MSSQL, or SQL Server, is a database system developed by Microsoft. Even when working with MSSQL, the basic SQL syntax remains largely the same:
|
1 2 3 4 |
SELECT * FROM Employees WHERE Salary > 2000; |
Summary
SQL provides a powerful, efficient, and flexible way to access and manipulate data in any relational database. By learning SQL, you’ll be gaining a core skill needed in data analysis, back-end web development, and more.
