
For an instructor lead, in-depth look at learning SQL click below.
SQL or Structured Query Language, is an integral tool for managing data stored in relational databases. This language is functionally powerful, and mastering it will give you significant leverage when dealing with data. Let’s journey together on the basics of SQL.
Understanding SQL
Commonly, SQL can carry out tasks such as data retrieval, updates, insertions, and deletions, among others from databases. It is declarative and using SQL; you’d issue orders to the database in a syntax interpretable by the database. Here is an example:
1 2 3 |
SELECT * FROM Employees |
This command will select all records from the ‘Employees’ table.
Basic SQL Commands
SELECT
This command is used to select data from a database. The data returned is stored in a result table, called the result-set. Here is an example:
1 2 3 |
SELECT column1, column2 FROM table_name; |
WHERE
The WHERE clause is used to filter records. It is used to extract only those records that fulfill a specified condition. See the example below:
1 2 3 |
SELECT column1, column2 FROM table_name WHERE condition; |
INSERT INTO
This statement is used to insert new data into a database. Check out the example below:
1 2 3 |
INSERT INTO table_name (column1, column2) VALUES (value1,value2); |
UPDATE
The UPDATE statement is used to modify the existing records in a table. Below is how to use it:
1 2 3 |
UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition; |
DELETE
The DELETE statement is used to delete existing records in a table. Like this:
1 2 3 |
DELETE FROM table_name WHERE condition; |
These are just the basics, but SQL has many more interesting features to explore such as JOIN, ALTER, DROP, CREATE. Mastering these commands will make you quite adept at dealing with databases. Happy learning!
`