SQL Selcting Multiple Tables Commands Flashcards
1
Q
What does the command Nested SELECT do and give example
A
A select within another select statement (nested). A mini select within the main one
Example:
SELECT * FROM users WHERE age > (SELECT AVG(age) FROM users);
(retrieves users with an age greater than the average age)
2
Q
What does the command JOIN do and give an example
A
Combines data from two or more tables based on a related column
Example:
SELECT users.name, orders.order_id FROM users
JOIN orders
ON users.user_id = orders.user_id;
(retrieves user names and their corresponding order IDs)