This concise overview provides a quick reference to using `LIMIT` and `ALIASING` in MySQL queries for effective data retrieval and manipulation
LIMIT` + ALIASING`
Limits in MySQL
‘LIMIT` Clause’ It is used to restrict the number of rows returned by a query. The syntax is `LIMIT [offset,] row_count` or `LIMIT row_count OFFSET offset`.
‘Example’
`SELECT * FROM employees LIMIT 5;` — returns the first 5 rows.
– ‘Example with Offset’ `SELECT * FROM employees LIMIT 5, 10;` — skips the first 5 rows and returns the next 10.
Aliasing in MySQL
-Column Aliasing: Allows renaming of column headings in the result set for better readability or to avoid conflicts.
– Syntax: `SELECT column_name AS alias_name FROM table_name;`
-Example’: `SELECT employee_id AS ID, employee_name AS Name FROM employees;`
-Table Aliasing:- Renames a table within a query, especially useful in complex queries or joins.
-Syntax:- `SELECT t.column_name FROM table_name AS t;`
– Example:-: `SELECT e.employee_name, d.department_name FROM employees AS e JOIN departments AS d ON e.department_id = d.id;`