Introduction
Table aliases let you give a short name to a table in a query. This makes writing and reading queries easier, especially when using multiple tables.
SELECT column_name(s) FROM table_name AS alias_name;
SELECT c.name FROM customers AS c;
SELECT o.id, c.name FROM orders o JOIN customers c ON o.customer_id = c.id;
SELECT e1.name, e2.name FROM employees e1 JOIN employees e2 ON e1.manager_id = e2.id;
CREATE TABLE customers (id INT, name VARCHAR(20)); INSERT INTO customers VALUES (1, 'Alice'), (2, 'Bob'); SELECT c.id, c.name FROM customers AS c;
table aliases in a SQL query?c to a table named customers in a SELECT query?orders and customers, what will the following query return?SELECT c.name, o.order_id FROM customers AS c JOIN orders AS o ON c.id = o.customer_id;
SELECT c.name, o.order_id FROM customers c JOIN orders o ON c.id = orders.customer_id;
employees table to itself to find pairs of employees who share the same manager. Which query correctly uses table aliases to achieve this?Pass the test and this pattern moves unknown