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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly