
For an instructor lead, in-depth look at learning SQL click below.
Structured Query Language, commonly known as SQL, is a standard programming language specifically designed for managing and manipulating databases. In this guide, we are going to explore the basics of SQL and how to write simple SQL queries.
What is SQL?
SQL is a domain-specific language intended for managing data held in relational databases or for stream processing in relational data stream management systems. It has become a standard tool for data scientists, database administrators, and back-end developers due to its simplicity and effectiveness in interacting with databases.
SQL Queries
An SQL query is a request for some action to be performed on a database. This could be for data retrieval, data manipulation (insert, update and delete) or even for database creation and modification.
Examples of SQL Code
The “SELECT” Query
The SELECT command is used to select data from a database. The data returned is stored in a result table.
1 2 3 |
SELECT * FROM Employees; |
In this example, * means “all”. Therefore, this SQL query selects all records from the “Employees” table.
The “WHERE” clause
The WHERE clause is used to filter records. It’s only used with SELECT, UPDATE, and DELETE statements.
1 2 3 |
SELECT * FROM Employees WHERE age > 30; |
This SQL query selects all records from the “Employees” table where the “age” is greater than 30.
INSERT INTO Statement
The “INSERT INTO” statement is used to insert new records into a table.
1 2 3 |
INSERT INTO Employees (FirstName, LastName, Age) VALUES ('John', 'Doe', 30); |
This SQL query inserts a new record into the “Employees” table.
Remember, the key to learning SQL (or any programming language) is practice! Try writing your own SQL queries and see what results you get. If you get stuck, don’t hesitate to ask for help. There are plenty of resources and communities online where you can find assistance. Happy querying!