Find the SQL. Understand the result.
SQLPathLab uses MySQL 8.0 by default and helps you find complete queries, real results, and common mistakes.
Site examples use MySQL 8.0 by default. Material dialect differences are called out only where needed.
Quick start
Start from a common taskSELECTSelects the columns or expressions returned by a query.WHEREFilters rows so only records matching a condition are returned.LEFT JOINKeeps all rows from the left table and adds matching right-table data.GROUP BYGroups rows by one or more columns for aggregation.CASE WHENReturns different values based on conditions.ROW_NUMBERAssigns a continuous number to rows after ordering or partitioning.DATE_FORMATFormats a date or datetime value as a specific string.INChecks whether a value exists in a list or subquery result.
Common SQL
Frequently used syntaxPractical SQL Guides
View all guidesSQL clause order and logical executionUnderstand the logical order of FROM, WHERE, GROUP BY, HAVING, SELECT, and ORDER BY.Why NULL and three-valued logic cause errorsNULL is not an empty string, and comparisons with NULL can be UNKNOWN.The real difference between WHERE and HAVINGWHERE filters source rows; HAVING filters groups after aggregation.Why JOIN creates duplicates or missing rowsDiagnose JOIN row-count changes through result grain, key uniqueness, and unmatched rows.LEFT JOIN filters in ON versus WHEREThe location of a right-table predicate determines whether unmatched left rows remain.COUNT(*), COUNT(column), and COUNT DISTINCTThe three forms answer row count, non-NULL value count, and unique-value count.