SQL statements end with a semicolon and follow a simple declarative structure:
SELECT * FROM customers;
DELETE FROM users WHERE id = 10;Keywords like SELECT, FROM, and WHERE are not case-sensitive. Table and column names may be case-sensitive depending on the database system.
SELECT: Specifies the columns or expressions you want to retrieve from the database.SELECT name, ageFROM: Indicates the table from which to retrieve the data.FROM usersWHERE: Filters the rows based on a specified condition.WHERE age > 18SQL queries are easier to read with proper indentation:
SELECT first_name, last_name
FROM employees
WHERE department = 'Sales';Use comments to explain complex sections of a query:
-- This is a single-line comment
/* This is
a multi-line comment */Use single quotes for string values:
SELECT * FROM users WHERE name = 'Alice';
SELECT * FROM orders WHERE amount > 100;Though we write SQL in a readable format, the database executes queries in the following logical order:
Ask the AI if you need help understanding or want to dive deeper in any topic