A Guide to SQL
9th Edition
ISBN: 9781111527273
Author: Philip J. Pratt
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 4, Problem 16CAT
Program Plan Intro
“SELECT” command:
The “SELECT” command is used to retrieve data in a
Syntax for selecting values from the table is as follows:
SELECT STUDENT_ID FROM STUDENT;
- The given query is used to display each student ID from “STUDENT” table.
“IN” Clause:
- The “IN” clause consists of an “IN” operator followed by a set of values.
- Using an “IN” clause, user can determine whether a column contains one of a particular group of values.
Example:
The example for “IN” clause is given below:
SELECT STUDENT_ID, STUDENT_NAME, STUDENT_CREDIT FROM STUDENT WHERE STUDENT_CREDIT IN(50, 70, 100);
The above query is used to list student ID, name, and credit for each student with a credit limit of “50”, “70” or “100”.
- From the given query, user can determine whether a student credit limit is “50”, “70” or “100” using an “IN” operator.
Subquery:
- Subquery means one query is placed inside with another query.
- The inner query is called a subquery.
- The subquery is calculated first.
- After the subquery has been determined and the outer query can apply the results of the subquery.
Example:
The example for subquery is given below:
SELECT ORDER_NUMBER FROM ORDER_LINE WHERE BOOK_NUMBER IN(SELECT BOOK_NUMBER FROM BOOKS WHERE CATEGORY = 'CE');
The above query is used to list the order number using subquery.
- From the given query, the subquery is “(SELECT BOOK_NUMBER FROM BOOKS WHERE CATEGORY = 'CE')”.
- The subquery is computed first and then outer query is computed.
- The outer query retrieves the order number on every row in the “ORDER_LINE” table for which the book number is in the results of the subquery.
- Because that table contains only the book numbers in category “CE”, the results display the preferred list of order numbers.
- The outer query retrieves the order number on every row in the “ORDER_LINE” table for which the book number is in the results of the subquery.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Find the rep number, last name, and first name of each sales rep who represents at least one customer with a credit limit of $10.000
If a subquery is used in the FROM clause of a query, how are the subquery’s results referenced in other clauses of the query?
Show all name and phone numbers of students and the type of donation they received including any unmatched student.table name;StudentDonationVolunteer
Chapter 4 Solutions
A Guide to SQL
Ch. 4 - Prob. 1RQCh. 4 - Prob. 2RQCh. 4 - Prob. 3RQCh. 4 - Prob. 4RQCh. 4 - Prob. 5RQCh. 4 - In which clause would you use a wildcard in a...Ch. 4 - Prob. 7RQCh. 4 - How do you determine whether a column contains one...Ch. 4 - Prob. 9RQCh. 4 - Prob. 10RQ
Ch. 4 - Prob. 11RQCh. 4 - Prob. 12RQCh. 4 - Prob. 13RQCh. 4 - Prob. 14RQCh. 4 - Prob. 15RQCh. 4 - Prob. 16RQCh. 4 - How do you find rows in which a particular column...Ch. 4 - Use the Internet to research the SQL [charlist]...Ch. 4 - Prob. 1TDCh. 4 - Prob. 2TDCh. 4 - Prob. 3TDCh. 4 - Prob. 4TDCh. 4 - Prob. 5TDCh. 4 - Prob. 6TDCh. 4 - Prob. 7TDCh. 4 - Prob. 8TDCh. 4 - Prob. 9TDCh. 4 - Prob. 10TDCh. 4 - Prob. 11TDCh. 4 - Prob. 12TDCh. 4 - Prob. 13TDCh. 4 - Prob. 14TDCh. 4 - Prob. 15TDCh. 4 - Prob. 16TDCh. 4 - What is the price of the least expensive item in...Ch. 4 - Prob. 18TDCh. 4 - Prob. 19TDCh. 4 - Prob. 20TDCh. 4 - Prob. 21TDCh. 4 - Prob. 22TDCh. 4 - Prob. 23TDCh. 4 - Prob. 1CATCh. 4 - Prob. 2CATCh. 4 - Prob. 3CATCh. 4 - Prob. 4CATCh. 4 - Prob. 5CATCh. 4 - Prob. 6CATCh. 4 - Prob. 7CATCh. 4 - Prob. 8CATCh. 4 - Prob. 9CATCh. 4 - Prob. 10CATCh. 4 - Prob. 11CATCh. 4 - Prob. 12CATCh. 4 - Prob. 13CATCh. 4 - Prob. 14CATCh. 4 - Prob. 15CATCh. 4 - Prob. 16CATCh. 4 - Prob. 17CATCh. 4 - Prob. 18CATCh. 4 - Prob. 19CATCh. 4 - List the reservation ID and trip ID for all trips...Ch. 4 - Prob. 1SCGCh. 4 - Prob. 2SCGCh. 4 - Prob. 3SCGCh. 4 - Prob. 4SCGCh. 4 - Prob. 5SCGCh. 4 - Prob. 6SCGCh. 4 - Prob. 7SCGCh. 4 - Prob. 8SCGCh. 4 - Prob. 9SCGCh. 4 - Prob. 10SCGCh. 4 - Prob. 11SCGCh. 4 - Prob. 12SCGCh. 4 - Prob. 13SCGCh. 4 - Prob. 14SCGCh. 4 - Prob. 15SCGCh. 4 - Prob. 16SCG
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- LIST THE FIRST AND LAST NAMES OF ALL OWNERS WHO OWN A TWO-BEDROOM PROPERTY. USE THE IN OPERATOR IN YOUR QUERYarrow_forwardUsing the WHERE clause, filter the invoice table to find the invoices that were dated after March 1st, 2009. Identify the first customer ID of the invoice. 17 2 19 16arrow_forwardDisplay the RID, RType and Bedroom of all ROOMS whose number of bedrooms is less than RID 105. Use subquery.arrow_forward
- Insert values in Nurse table you created in Q2 Nurse_id: Your roll no NurseName: Your Name Date of Birth: Nullarrow_forwardList the employee’s first and last name and the department name he/she does NOT belong topurchasing, shipping, or sales departments. Use Not operator.arrow_forwardUse a subquery to find employees' last names and hire date from the employees table whose manager is named "Hunold".arrow_forward
- List the customer ID and first and last names for all customers located in the city of Cody. Your query should ignore case. For example, a customer with the city Cody should be included, as should customers whose city is CODY, cody, cOdY, and so onarrow_forwardList all vendors with their address(city, state,zipcode) for all the vendors who have credited account (credit total>0)) Hint:Vendors & Invoices tables with credit total column WHERE vendors.vendor id = invoices.vendor id AND CREDIT_TOTAL>0; %3Darrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- A Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology Ptr
A Guide to SQL
Computer Science
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Course Technology Ptr