SQL Reference & Live Query Executor

Learn SQL syntax and run queries in your browser with sample database tables

SQL Query Editor
ℹ️ Note: SQL queries run entirely in your browser using SQLite (sql.js). For security, only SELECT queries are allowed. All data is sample data pre-loaded for practice.

Available Tables

Click "Run Query" to see data from these tables

Example Queries

Need to analyze sales data?

Try Cover Letter Pro →

Basic Queries

SELECT * FROM table_name;

Select all columns from a table

SELECT col1, col2 FROM table WHERE condition;

Select specific columns with filter

SELECT * FROM table ORDER BY col DESC;

Sort results descending

SELECT * FROM table LIMIT 10;

Limit number of results

Aggregations

SELECT COUNT(*) FROM table;

Count total rows

SELECT AVG(col) FROM table;

Calculate average

SELECT col, COUNT(*) FROM table GROUP BY col;

Group and count

SELECT SUM(col) FROM table WHERE condition;

Sum with condition

Joins

SELECT * FROM t1 JOIN t2 ON t1.id = t2.id;

Inner join (matching rows only)

SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id;

Left join (all rows from t1)

SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id;

Right join (all rows from t2)

Filters & Conditions

WHERE col = 'value'

Exact match

WHERE col LIKE '%pattern%'

Pattern matching

WHERE col IN (1, 2, 3)

Multiple values

WHERE col BETWEEN 10 AND 20

Range condition