SQL Playground

Write queries, analyze performance, and learn optimization techniques

Query Editor

Sample queries:
Analyzing...

Ready to analyze

Enter a query above and click "Analyze Query" to see results, insights, and optimization suggestions.

employees 20 rows
PK id
  name
FK department_id
FK manager_id
  salary
  hire_date
  email
  phone
departments 6 rows
PK id
  name
  budget
  location
customers 10 rows
PK id
  name
  email
  city
  country
  credit_limit
  created_at
products 12 rows
PK id
  name
  category
  price
  stock_quantity
  weight
  is_active
orders 15 rows
PK id
FK customer_id
FK employee_id
  order_date
  shipped_date
  status
  notes
order_items 26 rows
PK id
FK order_id
FK product_id
  quantity
  unit_price
  discount
Relationships
departments -> employees (department_id)
employees -> employees (manager_id)
customers -> orders (customer_id)
employees -> orders (employee_id)
orders -> products (order_items)

Try These Exercises

  • Write a query with SELECT * and see the warning, then fix it
  • Try WHERE YEAR(order_date) = 2023 and see the suggested rewrite
  • Experiment with LIKE '%phone%' to understand wildcard issues
  • Check the EXPLAIN tab to understand how MySQL would execute your query