Keywords
MySQL keywords are predefined reserved words that form the syntax and logic of SQL commands. They control the behavior of the database and should not be used as identifiers.
Common Uses of MySQL Keywords
- SELECT: Fetches data.
- FROM: Specifies the table.
- WHERE: Filters results.
- AND/OR: Combines conditions.
- DISTINCT: Ensures unique results.
Examples
- SELECT and FROM Keywords
SELECT name FROM employees;
Explanation: Fetches the
name
column from theemployees
table. - WHERE Keyword
SELECT * FROM orders WHERE amount > 100;
Explanation: Filters orders where
amount
exceeds 100. - AND/OR Keywords
SELECT * FROM users WHERE age > 18 AND active = 1;
Explanation: Filters users older than 18 and currently active.
- DISTINCT Keyword
SELECT DISTINCT department FROM employees;
Explanation: Retrieves unique department names from the
employees
table. - LIKE Keyword
SELECT * FROM customers WHERE name LIKE 'J%';
Explanation: Fetches customers whose names start with "J."