SQL JOIN commands

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is provided by a relational database management system (RDBMS) to join two or more tables?

A way of joining two or more tables with the use of different Structured Query Language (SQL) Join commands.

What are JOIN commands used for?

To combine rows from two or more tables.

A JOIN clause is used to combine rows from two or more tables, based on a related column between them.

True (A)

How can JOIN conditions be specified?

<p>Using either FROM or WHERE clauses (D)</p> Signup and view all the answers

How are joins categorized?

<p>All of the above (D)</p> Signup and view all the answers

What does an inner join use to match rows from two tables?

<p>A comparison operator.</p> Signup and view all the answers

A left outer join includes all the rows from the ______ table.

<p>left</p> Signup and view all the answers

A right outer join is the reverse of a left outer join.

<p>True (A)</p> Signup and view all the answers

What does a full outer join return?

<p>Returns all rows in both the left and right tables (A)</p> Signup and view all the answers

What are cartesian products also called?

<p>Cross joins.</p> Signup and view all the answers

In extracting records from tables, what is the key when extracting records from tables with a relationship?

<p>The common column that joins them.</p> Signup and view all the answers

What are the two categories that joins are categorized as?

<p>Inner Join and Outer Join.</p> Signup and view all the answers

What is an operator?

<p>A symbol or a reserved word specifying an action which evaluates the value expression either true or false and performs arithmetic operations</p> Signup and view all the answers

Conditional operators are also called comparison operators.

<p>True (A)</p> Signup and view all the answers

What do logical operators connect?

<p>two expressions (C)</p> Signup and view all the answers

What does the LIKE operator compare?

<p>A value to similar values using wildcard operators</p> Signup and view all the answers

The percent sign (%) represents a ______ of characters

<p>sequence</p> Signup and view all the answers

The underscore (_) represents a single number or character.

<p>True (A)</p> Signup and view all the answers

List two key Terms and their definition

<p>!= - is a symbol that denotes not equal. % - represents one or more sequence of characters.</p> Signup and view all the answers

Flashcards

SQL JOIN Clause

Combines rows from two or more tables based on related columns.

Inner Join

A JOIN where only matching rows between tables are returned.

Outer Join

Includes all rows from one table, plus matching rows from another. Includes NULL if no match.

Left Outer Join

All rows from the left table are included. No match in the right table results in NULL for right table columns.

Signup and view all the flashcards

Right Outer Join

All rows from the right table are included. No match in the left table results in NULL for left table columns.

Signup and view all the flashcards

Full Outer Join

Returns all rows from BOTH tables. Unmatched rows contain NULL values.

Signup and view all the flashcards

Cross Join

Combines each row from one table with every row from another table.

Signup and view all the flashcards

Cartesian Product

Another name for a Cross Join, resulting in all possible row combinations.

Signup and view all the flashcards

Common Key

A column common to two or more tables that is used to establish a relationship.

Signup and view all the flashcards

View

A virtual table based on the result-set of an SQL statement.

Signup and view all the flashcards

Operator

A symbol that specifies an action or condition.

Signup and view all the flashcards

Conditional Operator

Evaluates if an expression is true or false.

Signup and view all the flashcards

Logical Operator

Connects two expressions and tests their conditional values.

Signup and view all the flashcards

AND Operator

Requires all conditions to be true.

Signup and view all the flashcards

BETWEEN Clause

Filters data within a specified range.

Signup and view all the flashcards

IN Clause

Filters data based on a list of values.

Signup and view all the flashcards

LIKE Clause

Compares a value to a similar specified value using wildcards.

Signup and view all the flashcards

Logical Operator

Combines two or more expressions.

Signup and view all the flashcards

NOT IN Clause

Filters data NOT within a specified range.

Signup and view all the flashcards

Underscore (_) in LIKE

Wildcard representing a single character.

Signup and view all the flashcards

WHERE Clause

Filters data based on a given expression.

Signup and view all the flashcards

What type of join includes all rows from the left table?

Left Join (or Left Outer Join)

Signup and view all the flashcards

What type of join includes all rows from the right table?

Right Join (or Right Outer Join)

Signup and view all the flashcards

What type of join only returns matching rows?

Inner Join

Signup and view all the flashcards

What type of join returns ALL rows from both tables?

Full Outer Join

Signup and view all the flashcards

What type of join returns the Cartesian product of two tables?

Cross Join

Signup and view all the flashcards

What is a virtual table based on a SQL query?

View

Signup and view all the flashcards

What type of operator evaluates an expression to TRUE or FALSE?

Conditional Operators (=, >, <, etc.)

Signup and view all the flashcards

What are examples of logical operators?

AND, OR, NOT

Signup and view all the flashcards

Which clause enables wildcard character-based filtering?

LIKE Clause

Signup and view all the flashcards

Study Notes

  • Relational Database Management Systems (RDBMS) use Structured Query Language (SQL) Join commands to join tables.
  • Join commands can combine rows from two or more tables.
  • Exact values are produced using conditional parameters added with the WHERE clause.

SQL Join

  • A JOIN clause combines rows from two or more tables based on a related column.
  • JOIN conditions can be specified using either FROM or WHERE clauses.
  • FROM clause is recommended for specifying JOIN conditions.
  • WHERE and HAVING clauses can contain search conditions to further filter rows.

Types of Joins

  • Joins are categorized as inner joins and outer joins.

Inner Join

  • The typical join uses a comparison operator (= or <>) to match rows from two tables.
  • Matching is based on values in common columns.

Outer Join

  • Outer joins can be left, right, or full outer joins.
  • They are specified with keywords in the FROM clause.

Left Join (Left Outer Join)

  • The result set includes all rows from the left table specified in the left outer clause.
  • If a row in the left table has no matching rows in the right table, the result set contains null values for select list columns from the right table.

Right Join (Right Outer Join)

  • A right outer join is the reverse of a left outer join.
  • All rows from the right table are returned.
  • Null values are returned for the left table when a right table row has no matching row in the left table.

Full Join (Full Outer Join)

  • A full outer join returns all rows in both the left and right tables.
  • If a row has no match in the other table, the select list columns from the other table contain null values.
  • When tables match, the result set row contains data values from the base tables.

Cross Join

  • Cross join returns all rows from the left table, combined with all rows from the right table.
  • Cross joins are also called Cartesian products.
  • Cartesian products multiply the value of one table to the joined table.

Key Understanding:

  • Extracting records relies on a common column (key) that joins tables.
  • Joins enable connections between tables using a primary key.

Creating a View

  • Right-click the View folder, then select New View to create a view.
  • The View design is divided into four panes: diagram, criteria, SQL query, and results.
  • The diagram shows column names of each table; commands are generated by connecting tables.
  • The SQL query pane allows coding commands, automatically generating SQL commands when the diagram pane is triggered.

Operators in the WHERE Clause

  • An operator is a symbol or reserved word that specifies an action, evaluating the expression as true or false.

Conditional Operators

  • Conditional operators are also called comparison operators.
  • They evaluate whether expressions yield a true or false value.
  • They can be used in all expressions except those with text, next, or image data types.

Logical Operators

  • Logical operators connect two expressions and test their conditional values.

  • Like comparison operators, they have a Boolean data type with a value of true or false

  • The AND operator displays records when all conditions are TRUE.

  • The OR operator displays records that meet either or both conditions.

SQL LIKE Operator & Wildcard Characters

  • The SQL LIKE operator compares a value to similar values using wildcard operators.
  • It allows matching searches and returns a Boolean type (true/1 or false/0) value for a character string data type.

Wildcard Characters

  • Percent Sign (%): Represents a sequence of zero, one, or multiple characters.
  • Underscore (_): Represents a single number or character.
  • [charlist]: Represents a single character within a character list.
  • [^charlist]: Represents any single character NOT in the list.

Key Terms

  • Column list: List of column names in a table.
  • Table name: The name of the table to be used in the SELECT command.
  • WHERE: A keyword in a SELECT command that tests whether an expression is true or false.
  • LIKE: A clause which replaces the comparison operator.
  • Pattern: A string of up to 8,000 characters to search for, provided by a wildcard character.
  • SQL LIKE Operator: A powerful filter for thorough searches, but may expose or produce garbage results.
  • Ending Character String: Place the percent sign (%) at the end of the character string to display.
  • Beginning Character String: Place the percent sign (%) at the beginning of the character string to locate.
  • ORDER BY Command: Sorts the list.
  • !=: means not equal.
  • %: Represents one or more sequences of characters.
  • [ ]: Wildcard operator representing a character list.
  • [^]: Wildcard operator representing anything other than a character list.
  • < > =: Means not equal.
  • Between Clause: Filters data within a given range.
  • Conditional Operator: Evaluates a Boolean expression to either true or false.
  • In Clause: Filters data within the given range.
  • Like Clause: Compares a value similar to a specified one with a wildcard character.
  • Logical Operator: Combines two or more expressions.
  • Not In Clause: Filters data not within the given range.
  • Underscore (_): Denotes a single character in the Like operator used in the Where clause.
  • Where Clause: Filters data based on the given expression.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Mastering SQL JOIN and Inner Join
3 questions
SQL JOIN Clauses Quiz
10 questions
Information Management Week 15: SQL Join
16 questions
SQL: DML Bagian 2 - JOIN
23 questions

SQL: DML Bagian 2 - JOIN

PermissibleZircon702 avatar
PermissibleZircon702
Use Quizgecko on...
Browser
Browser