SQL data manipulation

SQL provides powerful commands to interact with relational databases. Among the most commonly used commands are SELECT, FROM, WHERE, ORDER BY and INNER JOIN, which together enable efficient retrieval, filtering, sorting and linking of data across tables.

  1. SELECT: Specifies the columns to retrieve from a database. It is the core command for extracting data.
    • Example: SELECT Name, Age FROM Employees;
  2. FROM: Identifies the table or tables where the data resides. It works alongside SELECT to define the source.
    • Example: FROM Orders;
  3. WHERE: Applies conditions to filter data based on specific criteria, ensuring only relevant records are retrieved.
    • Example: WHERE Age > 30;
  4. ORDER BY: Sorts the retrieved data in ascending or descending order based on one or more columns.
    • Example: ORDER BY Salary DESC;
  5. INNER JOIN: Links two or more tables based on a related column, allowing access to combined data from multiple tables.
    • Example: INNER JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID;

Together, these commands form the backbone of SQL queries, enabling users to manipulate and analyse data with precision and efficiency. By mastering these commands, users can handle complex data requirements and extract valuable insights from relational databases.

Reflection: Thinking about SQL

Read and reflect upon these two questions:

  • SQL's impact: How can mastering SQL make you a better data detective, helping you uncover hidden patterns and make smarter decisions?
  • Ethical considerations: As we gain greater control over data through SQL, what ethical responsibilities do we have to ensure that data is used responsibly and for the benefit of society?