PublicSoftTools
Tools16 min read·PublicSoftTools Team·May 2026

SQL Query Tester — Test and Run SQL Queries Online

Testing SQL queries typically requires setting up a database, importing data, and connecting a client — significant overhead when you just want to verify a query's logic. The SQL query tester on PublicSoftTools runs queries directly in your browser using an in-memory SQLite database — no installation, no server, no account. Create tables, insert data, and test any SQL query instantly.

SQL Command Categories

CategoryCommandsExamplePurpose
DDL (Data Definition)CREATE TABLE, ALTER TABLE, DROP TABLECREATE TABLE employees (id INT, name TEXT, salary REAL);Define the structure of database tables
DML (Data Manipulation)INSERT, UPDATE, DELETEINSERT INTO employees VALUES (1, 'Alice', 50000);Add, modify, or remove data in tables
DQL (Data Query)SELECT, FROM, WHERE, ORDER BY, GROUP BY, HAVINGSELECT name, salary FROM employees WHERE salary > 40000;Retrieve and filter data from tables
JoinsINNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOINSELECT e.name, d.dept FROM employees e INNER JOIN departments d ON e.dept_id = d.id;Combine data from multiple related tables
Aggregate functionsCOUNT(), SUM(), AVG(), MIN(), MAX()SELECT dept, AVG(salary) FROM employees GROUP BY dept;Calculate summary statistics over groups of rows
SubqueriesNested SELECT in WHERE, FROM, or SELECT clauseSELECT name FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);Use query results as input to another query

How to Use the SQL Query Tester

  1. Open the SQL query tester.
  2. Use the schema panel to create tables with CREATE TABLE statements, or load one of the sample schemas (employees, products, orders).
  3. Insert data using INSERT INTO statements in the schema panel, or load sample data.
  4. Write your SQL query in the query editor.
  5. Click Run (or press Ctrl+Enter) to execute the query.
  6. Results appear in the table below. Error messages are displayed inline with the query if the SQL is invalid.
  7. Use the Format button to automatically format your SQL for readability.

SQL JOIN Types Explained

Join typeReturnsUse caseExample
INNER JOINOnly rows where the join condition matches in both tablesMost common — find matching records between tablesEmployees with a department entry (unassigned employees excluded)
LEFT JOINAll rows from the left table; NULL for unmatched right table columnsInclude all records from the primary table regardless of matchesAll employees, even those without a department assigned yet
RIGHT JOINAll rows from the right table; NULL for unmatched left table columnsLess common; usually rewritten as a LEFT JOIN with tables swappedAll departments, even those with no employees yet
FULL OUTER JOINAll rows from both tables; NULL where no match exists on either sideFind all records from both tables and see which have no matchAll employees and all departments, showing unmatched on both sides
CROSS JOINCartesian product — every row in left table combined with every row in right tableGenerate all combinations; rarely used in productionAll possible employee-project pairings before applying filters

Writing Your First SQL Query

The basic SELECT query retrieves data from a table:

SELECT column1, column2 FROM table_name WHERE condition ORDER BY column1;

Breakdown:

To test in the SQL tester: create a table, insert a few rows, then run a SELECT to verify the data and filtering.

Aggregate Queries and GROUP BY

Aggregate functions (COUNT, SUM, AVG, MIN, MAX) calculate a single value from a set of rows. They are used with GROUP BY to calculate per-group statistics:

SELECT department, COUNT(*) AS headcount, AVG(salary) AS avg_salary FROM employees GROUP BY department ORDER BY avg_salary DESC;

Key rules for GROUP BY:

Subqueries

A subquery is a SELECT statement nested inside another query. Subqueries can appear in the WHERE clause, FROM clause, or SELECT clause:

Scalar subquery (returns one value):

SELECT name, salary FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);

Correlated subquery (references the outer query):

SELECT name FROM employees e WHERE salary = (SELECT MAX(salary) FROM employees WHERE department = e.department);

Correlated subqueries can be slow on large datasets — consider rewriting as a JOIN or using window functions (which SQLite supports from version 3.25+).

Common SQL Errors and Fixes

SQL Formatting Best Practices

Well-formatted SQL is easier to read, debug, and review. The SQL formatter automatically applies standard formatting. Key conventions:

Common Questions

Does the SQL tester support all SQL databases?

The SQL tester uses SQLite, which supports most standard SQL syntax. Some vendor-specific features differ: MySQL uses LIMIT, SQL Server uses TOP, Oracle uses ROWNUM or FETCH FIRST. For subqueries, JOINs, GROUP BY, and most common DML operations, SQLite syntax is compatible with other major databases. Test edge cases against your actual database before production use.

Can I save my queries?

The SQL tester allows you to export your schema and queries. Use the export button to download your SQL as a .sql file, which you can save locally and reimport in a future session. Browser local storage may save recent queries for convenience, but is not a permanent storage solution.

What is the difference between WHERE and HAVING?

WHERE filters individual rows before any aggregation occurs. HAVING filters groups after aggregation. You cannot use aggregate functions (SUM, COUNT, AVG) in a WHERE clause — that's what HAVING is for. Example: WHERE salary > 50000 filters individual employee rows; HAVING AVG(salary) > 50000 filters department groups whose average exceeds 50,000.

Test SQL Queries Online

Create tables, insert data, and run SQL queries instantly in your browser — no database setup, no installation needed.

Open SQL Query Tester