SQL

SQL Tutorial

Query and change data – SELECT, WHERE, sorting, joins, grouping and table design.

SQL is how you ask a database for data. In this track you write real queries against a small sample shop database – customers, products and orders – right in your browser: filtering, sorting, joining tables, grouping and creating tables with keys and constraints.

The examples use SQLite, and each lesson points out where MySQL or SQL Server differ.

  1. 1 SQL IntroductionLearn what SQL is, how relational databases store data in tables, and run your first query against a small grocery-shop…
  2. 2 SQL SELECTUse SELECT to read columns, rename them with AS, calculate new values and remove duplicate rows with DISTINCT.
  3. 3 SQL WHEREFilter rows with WHERE: comparison operators, AND, OR, NOT, brackets, and the special way SQL handles missing values with IS…
  4. 4 SQL ORDER BY and LIMITSort query results with ORDER BY, pick the top rows with LIMIT, and split long lists into pages with OFFSET.
  5. 5 SQL INSERT, UPDATE and DELETEAdd new rows with INSERT, change existing rows with UPDATE and remove rows with DELETE – safely, with WHERE and…
  6. 6 SQL Aggregate FunctionsSummarise many rows into one answer with COUNT, SUM, AVG, MIN and MAX, and learn how each function treats NULL…
  7. 7 SQL GROUP BY and HAVINGGroup rows with GROUP BY to get counts and totals per department, state or customer, then filter those groups with…
  8. 8 SQL JoinsCombine rows from several tables with INNER JOIN, LEFT JOIN and self joins, and see where SQLite, MySQL and SQL…
  9. 9 SQL LIKE and WildcardsSearch text by pattern with LIKE and the % and _ wildcards, handle case sensitivity, and escape special characters.
  10. 10 SQL IN and BETWEENShorten long WHERE conditions with IN for lists of values and BETWEEN for ranges of numbers, dates and text.
  11. 11 SQL CREATE TABLEDesign your own tables with CREATE TABLE: choose data types, add an auto-numbered ID and defaults, then change or remove…
  12. 12 SQL Constraints and KeysProtect your data with PRIMARY KEY, FOREIGN KEY, NOT NULL, UNIQUE, CHECK and DEFAULT, and learn why SQLite needs foreign…