BuyFindarrow_forward

A Guide to SQL

9th Edition
Philip J. Pratt
Publisher: Course Technology Ptr
ISBN: 9781111527273
Chapter 5, Problem 16SCG
Textbook Problem
71 views

Repeat Exercise 15 using a different SQL command to obtain the same result. What is the difference between the two commands?

Program Plan Intro

RIGHT JOIN:

  • This type of join returns all the records (rows) from the right table and the matched records (rows) from the left table.
  • When the fields of left table do not match with the right one, then the fields are filled with “NULL” values.

Syntax:

SELECT column_Name(s) FROM table_Name1 RIGHT JOIN table_Name2 ON table_Name1.column_Name = table_Name2.column_Name;

In the above syntax, the right table is “table_Name2” and the left table is “table_Name1”.

Explanation of Solution

SQL code:

The SQL code is to list condo id, square footage, owner number, service ID, number of estimated hours and number of hours spent for every service request whose category number is equal to 4. Here, every condo should be included. The query is as follows.

SELECT CU.CONDO_ID, SQR_FT, OWNER_NUM, SERVICE_ID, EST_HOURS, SPENT_HOURS FROM SERVICE_REQUEST RIGHT JOIN CONDO_UNIT CU ON CU.CONDO_ID = SERVICE_REQUEST.CONDO_ID AND CATEGORY_NUM = 4 ORDER BY CU.CONDO_ID;

Explanation:

The above query displays “CONDO_ID”, “SQR_FT”, “OWNER_NUM”, “SERVICE_ID”, “EST_HOURS”, and “SPENT_HOURS” from the table “SERVICE_REQUEST” which is right joined with the table “CONDO_UNIT”. The list produced is based on the matching “CONDO_ID” from both the tables and the “CATEGORY_NUM” should be equal to 4. The result set is finally ordered by “CONDO_ID”.

Difference between left and right join:

LEFT JOINRIGHT JOIN

This type of join returns all the records (rows) from the left table and the matched records (rows) from the right table...

Still sussing out bartleby?

Check out a sample textbook solution.

See a sample solution

The Solution to Your Study Problems

Bartleby provides explanations to thousands of textbook problems written by our experts, many with advanced degrees!

Get Started

Chapter 5 Solutions

A Guide to SQL
Show all chapter solutions
add
Ch. 5 - Which rows are included in an inner join? What...Ch. 5 - Which rows are included in a left outer join? What...Ch. 5 - Which rows are included in a right outer join?...Ch. 5 - What is the formal name for the product of two...Ch. 5 - Use the Internet to find definitions for the terms...Ch. 5 - For each order, list the order number and order...Ch. 5 - For each order placed on October 15, 2015, list...Ch. 5 - For each order, list the order number, order date,...Ch. 5 - Use the IN operator to find the number and name of...Ch. 5 - Repeat Exercise 4, but this time use the EXISTS...Ch. 5 - Find the number and name of each customer that did...Ch. 5 - For each order, list the order number, order date,...Ch. 5 - Repeat Exercise 7, but this time order the rows by...Ch. 5 - Use a subquery to find the rep number, last name,...Ch. 5 - Repeat Exercise 9, but this time do not use a...Ch. 5 - Find the number and name of each customer that...Ch. 5 - List the item number, description, and category...Ch. 5 - List the order number and order date for each...Ch. 5 - List the order number and order date for each...Ch. 5 - List the order number and order date for each...Ch. 5 - List the order number and order date for each...Ch. 5 - List the order number and order date for each...Ch. 5 - List the item number, description, unit price, and...Ch. 5 - If you used ALL in Exercise 18, repeat the...Ch. 5 - For each rep, list the customer number, customer...Ch. 5 - For each reservation, list the reservation ID,...Ch. 5 - For each reservation for customer Ryan Goff, list...Ch. 5 - List the trip name of each trip that has Miles...Ch. 5 - List the trip name of each trip that has the type...Ch. 5 - For each reservation that has a trip date of July...Ch. 5 - List the reservation ID, trip ID, and trip date...Ch. 5 - Repeat Exercise 6, but this time use the EXISTS...Ch. 5 - Find the guide last name and guide first name of...Ch. 5 - Repeat Exercise 8 but use aliases for the table...Ch. 5 - List the trip IDs and trip names (or each pair of...Ch. 5 - Find the trip name of all reservations for hiking...Ch. 5 - List the number and name of each customer that...Ch. 5 - List the number and name of each customer that...Ch. 5 - Find the trip ID and trip name for each trip whose...Ch. 5 - Find the trip ID and trip name for each trip whose...Ch. 5 - Display the trip ID, trip name, and reservation ID...Ch. 5 - Repeat Exercise 8 but list the guide name only...Ch. 5 - Repeat Exercise 10, but this time list only hiking...Ch. 5 - For every condo, list the location number, unit...Ch. 5 - For every completed or open service request for...Ch. 5 - For every service request for janitorial work,...Ch. 5 - List the first and last names of all owners who...Ch. 5 - Repeat Exercise 4, but this time use the EXISTS...Ch. 5 - List the unit numbers of any pair of condos that...Ch. 5 - List the square footage, owner number, owner last...Ch. 5 - Repeat Exercise 7, but this time include only...Ch. 5 - List the location number, unit number, and condo...Ch. 5 - List the location number, unit number, and condo...Ch. 5 - List the location number, unit number, and condo...Ch. 5 - Find the service ID and condo ID for each service...Ch. 5 - Find the service ID and condo ID for each service...Ch. 5 - List the condo ID, square footage, owner number,...Ch. 5 - Repeat Exercise 14, but this time be sure each...Ch. 5 - Repeat Exercise 15 using a different SQL command...

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Show solutions add
What are the main components of a database system?

Database Systems: Design, Implementation, & Management

What is PCI DSS and why is it important for information security?

Principles of Information Security (MindTap Course List)

Write a brief report detailing the development of safety belts in cars. When was the first safety belt designed...

Engineering Fundamentals: An Introduction to Engineering (MindTap Course List)

If your motherboard supports ECC DDR3 memory, can you substitute non-ECC DDR3 memory?

A+ Guide to Hardware (Standalone Book) (MindTap Course List)

What steps can you take to strengthen a wireless signal? (471)

Enhanced Discovering Computers 2017 (Shelly Cashman Series) (MindTap Course List)

What is the last weld bead on a multipass weld called?

Welding: Principles and Applications (MindTap Course List)