Core commands
This demo uses a small in-memory customer table so you can see results and errors.
Execution preview
Click Execute to run the current query and see the result or error.
Use these examples to learn common commands, join patterns, and safer SQL habits. This page is designed for study and demo use on the shared site at meatgon.com/sql.
Click Execute to run the current query and see the result or error.
Joins combine rows from multiple tables using a related column.
CREATE TABLE customers ( customer_id INT PRIMARY KEY, customer_name VARCHAR(100), city VARCHAR(100) ); CREATE TABLE orders ( order_id INT PRIMARY KEY, customer_id INT, total DECIMAL(10,2) ); INSERT INTO customers VALUES (1, 'Mina', 'Seattle'); INSERT INTO customers VALUES (2, 'Leo', 'Denver'); INSERT INTO orders VALUES (101, 1, 45.00); INSERT INTO orders VALUES (102, 2, 80.00); SELECT c.customer_name, o.order_id, o.total FROM customers c INNER JOIN orders o ON c.customer_id = o.customer_id;
The safest approach is to use parameterized queries instead of concatenating input into SQL text.
"SELECT * FROM users WHERE name = '" + input + "'".// Safe example in PHP
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = :username");
$stmt->execute([":username" => $userInput]);