SELECT column FROM table_name
-- Limit number of rows to 10
LIMIT 10
SELECT column FROM table_name
-- Will return results starting from the specified offset value
OFFSET number_of_rows
The basic syntax of the SQL WHERE clause is as follows:
SELECT column1, column2, ... FROM table_name WHERE condition;
You can use logical operators (AND, OR, NOT) to create more complex conditions in the WHERE clause. For instance, to retrieve employees with a salary greater than 50000 and belonging to the "Sales" department, you can use the AND operator as follows:
SELECT * FROM employees WHERE salary > 50000 AND department = 'Sales';
Comparison operators (e.g., =, <>, >, <, >=, <=) are used to compare values in the WHERE clause. For example, to retrieve products with a unit price less than 50, you can use the following query:
SELECT product_name, unit_price FROM products WHERE unit_price < 50;
The WHERE clause can also be used with wildcard characters for pattern matching. For instance, to retrieve all customers with names starting with "Joh," you can use the LIKE operator and the '%' wildcard as follows:
SELECT * FROM customers WHERE customer_name LIKE 'Joh%';
To create more complex conditions, you can use parentheses to group logical expressions. For example, to retrieve products with a unit price less than 50 or belonging to the "Electronics" category, you can use parentheses and the OR operator as follows:
SELECT product_name, unit_price, category FROM products WHERE (unit_price < 50 OR category = 'Electronics');
To filter rows based on NULL values, you can use the IS NULL or IS NOT NULL operators. For example, to retrieve employees with no assigned manager, you can use the following query:
SELECT * FROM employees WHERE manager_id IS NULL;