Chapter 05 Using Joins and Subqueries Flashcards

1
Q

A join is

A

A join is a query that combines rows from two or more tables or views. Joins are used to relate two or more tables (or views).

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

Inner Join

A

Inner joins return only the rows that satisfy the join condition. The most common operator
used to relate two tables is the equality operator (=). If you relate two tables using an equality
operator, it is an equality join, also known as an equijoin. This type of join combines rows
from two tables that have equivalent values for the specified columns.

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

Simple Inner Joins

A

A simple inner join has only the join condition specified, without any other filtering conditions.

SELECT locations.location_id, city, department_name
FROM locations, departments WHERE locations.location_id = departments.location_id;

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

Natural Join

A

The NATURAL keyword indicates a natural join, where the join is based on all columns that have the same name in both tables. In this type of join, you should not qualify the column names with the table name or table alias name.

SELECT location_id, city, department_name FROM locations NATURAL JOIN departments;

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

Outer Joins

A

An outer join returns results based on the inner join condition, as well as the unmatched rows from one or both of the tables.

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

left outer join

A

A left outer join is a join between two tables that returns rows based on the matching condition,
as well as unmatched rows from the table to the left of the JOIN clause.

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

right outer join

A

A right outer join is a join between two tables that returns rows based on the matching
condition, as well as unmatched rows from the table to the right of the JOIN clause.

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

self-join

A

A self-join joins a table to itself. The table name appears in the FROM clause twice, with different
alias names. The two aliases are treated as two different tables, and they are joined as
you would join any other tables, using one or more related columns.

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

UNION

A

Returns all unique rows selected by either query. The UNION operator is used to return rows from either query, without any duplicate rows.

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

UNION ALL

A

Returns all rows, including duplicates selected by

either query. The UNION ALL operator does not sort or filter the result set; it returns all rows from both queries.

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

INTERSECT

A

Returns rows selected from both queries. The INTERSECT operator is used to return the rows returned by both queries.

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

What is a subquery?

A

A subquery is a query within a query. A subquery answers the queries that have multiple parts; the subquery answers one part of the question, and the parent query answers the other part. When you nest several subqueries, the innermost query is evaluated first.

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

If the join condition uses the equality operator (= or IN), it is known as an [Blank]. If any other operator is used to join the tables, it is a [Blank].

A

equality join.

nonequality join

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

What is the EXIST operator?

A

The EXISTS operator checks for the existence of a row in the subquery based on the condition.

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

The IN operator is equivalent

to [Blank]

A

=ANY

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