Additional data storage techniques

SQL Structured Query Language

SQL (Structured Query Language) is a standard language used to communicate with and manipulate databases. Here are the fundamental ```sql commands

SELECT

  • Purpose: Used to retrieve data from a database.

Syntax

SELECT column1, column2, ...
FROM table_name;
SELECT Name, Score
FROM Students;

FROM

  • Purpose: Specifies the table from which to retrieve data.

Syntax

SELECT column1, column2, ...
FROM table_name;

WHERE

  • Purpose: Filters records to only include those that meet a specified condition.

Syntax

SELECT column1, column2, ...
FROM table_name
WHERE condition;
SELECT Name, Score
FROM Students
WHERE Score > 80;

Using SQL to Search for Data

SQL is highly effective for searching and filtering data based on specific criteria.

To find students with scores above 85:

SELECT Name, Score
FROM Students
WHERE Score > 85;

This command will return all records from the Students table where the Score is greater than 85.

Using * to Search for Data

To find all students fields you can use the * command

SELECT *
FROM Students
WHERE Score > 85;

This command will return all records from the Students table where the Score is greater than 85 and include all fields in the returned data set.

Using = to Search for Data

To find all students fields you can use the * command

SELECT *
FROM Students
WHERE Score = 85;

This command will return all records from the Students table where the Score is equal to 85 and include all fields in the returned data set.

Key Points

  • SELECT: Retrieve specific columns from a table.
  • FROM: Specify the table to retrieve data from.
  • WHERE: Apply conditions to filter the results.

SQL provides a powerful way to query and manipulate data in relational databases, making it an essential tool for database management and data analysis.

Practical Practice

Try putting in the following examples

SELECT * 
FROM Customers
Where Country="Germany";
SELECT CustomerName
FROM Customers
Where Country="Germany";
SELECT ProductName, Price
FROM Products
Where Price<20;
Previous
Use of records to store data