💾 SQL Playground
Write and run SQL queries against a mock employee database with live results
Query Editor
SQLResults
Schema
Examples
Interview Questions
Q1: What is the difference between WHERE and HAVING?
WHERE filters individual rows before aggregation, while HAVING filters groups after GROUP BY. WHERE cannot use aggregate functions, HAVING can.
Q2: What is the difference between INNER JOIN and LEFT JOIN?
INNER JOIN returns only rows with matching keys in both tables. LEFT JOIN returns all rows from the left table, with NULLs for non-matching columns from the right table.
Q3: What is a primary key?
A column (or set of columns) that uniquely identifies each row. It must contain unique, non-NULL values. Each table can have only one primary key.
Q4: What is the difference between DELETE and TRUNCATE?
DELETE removes rows one by one (can have WHERE, fires triggers, can be rolled back). TRUNCATE removes all rows at once (cannot use WHERE, minimal logging, cannot roll back in most DBMS).
Q5: What is an index and how does it speed up queries?
An index is a data structure (typically a B-tree) that provides fast lookup of rows based on column values, avoiding full table scans. It speeds up SELECT and WHERE at the cost of slower INSERT/UPDATE.