Question

More on JOINS Log in to your ApEX SQL account. Two Table Join Create a SQL...

More on JOINS

  1. Log in to your ApEX SQL account.

Two Table Join

  1. Create a SQL query that gets the order ID, order_mode, customer ID and product ID from the ORDERS and ORDER_ITEMS tables. You will have to join the tables on some common column.

Two Table Join With Subquery

  1. Modify the previous query and add a subquery that looks for the existence of a customer ID in the CUSTOMERS table. This is a correlated sub-query so you will have to match the customer ID from the sub-query to the customer ID in the outer query.

Three Table Join with Subquery

  1. Modify the previous SQL query the add the translated name column from the PRODUCT_DESCRIPTIONS table.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

-- 1)

SELECT O.order_id, order_mode, customer_id, product_id

FROM ORDERS AS O INNER JOIN ORDER_ITEMS AS OI ON O.order_id = OI.order_id;

-- 2)

SELECT O.order_id, order_mode, customer_id, product_id

FROM ORDERS AS O INNER JOIN ORDER_ITEMS AS OI ON O.order_id = OI.order_id

WHERE EXISTS(

    SELECT *

    FROM CUSTOMERS C

    WHERE O.customer_id = C.customer_id);

-- 3)

SELECT O.order_id, order_mode, customer_id, P.product_id, description

FROM (ORDERS AS O INNER JOIN ORDER_ITEMS AS OI ON O.order_id = OI.order_id) INNER JOIN PRODUCT_DESCRIPTIONS P ON OI.product_id = P.product_id

WHERE EXISTS(

    SELECT *

    FROM CUSTOMERS C

    WHERE O.customer_id = C.customer_id);

Add a comment
Know the answer?
Add Answer to:
More on JOINS Log in to your ApEX SQL account. Two Table Join Create a SQL...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • CIS 411w spring 2017 Problem Set 11    1 Log in to your Oracle ApEx account....

    CIS 411w spring 2017 Problem Set 11    1 Log in to your Oracle ApEx account. 2. Create a new table called email with this command: CREATE table email as (SELECT empno, ename||'.'||SUBSTR(JOB,1,2)||'@apex.com' as "EMAIL" from emp); Click à Run to create this table 3. Write a SQL query that JOINS the three tables emp,dept and email. This SQL query will return the empno, ename, job, sal, loc and email for each employee. Use the newer ANSI JOIN syntax rather...

  • Create the database and tables for the database. Show all SQL statements. Include primary and foreign...

    Create the database and tables for the database. Show all SQL statements. Include primary and foreign keys. Insert data into each table. Show select statements and display the output of each table. Note:Student’s name must be inserted into table as part of the data! Perform the SQL below: Query one table and use WHERE to filter the results. The SELECT clause should have a column list, not an asterisk (*). State the purpose of the query; show the query and...

  • Write an SQL query A related table to snp151 is named snp151CodingDbSnp, which stores data about ...

    write an SQL query A related table to snp151 is named snp151CodingDbSnp, which stores data about changes in protein sequence related to SNPs. For this query, you will extract data from both tables using a join. The query results should have the SNP name, chromosome, strand and start position from the snp151 table, AND the transcript, codons & peptides from the snp151CodingDbSnp table. Q2: Modify Q1 to only include SNPs that are in frame 2. Q3: Modify Q2 to only...

  • Tables: Create table Item(                 ItemId                 char(5) constraint itmid_unique primar

    Tables: Create table Item(                 ItemId                 char(5) constraint itmid_unique primary key,                 Decription           varchar2(30),                 Unitcost               number(7,2)); Create table Customer(                 custID                   char(5) constraint cid.unique primary key,                 custName          varchar2(20),                 address                                varchar2(50)); Create table Orderdata( orderID                char(5) constraint oid_uniq primary key,                 orderdate           date,                 shipdate              date,                 ItemId                  char(5) references Item.ItemId,                 No_of_items     number(4),                 Unitcost               number(7,2),                 Order_total        number(7,2),                 custID                   char(5) references customer.custID); Insert Into Item values(‘A123’,’Pencil’,2.5); Insert Into Item values(‘B123’,’Pen’,15); Insert Into...

  • SQL Homework exercises: 1. Write INSERT statements that add two rows to the Members table for...

    SQL Homework exercises: 1. Write INSERT statements that add two rows to the Members table for member IDs 1 and 2, two rows to the Groups table for group IDs 1 and 2, and three rows to the Group_Membership table: one row for member 1 and group 2; one for member 2 and group 1; and one for member 2 and group 2. Then, write a SELECT statement that joins the three tables and retrieves the group name, member last...

  • Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the p...

    Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the publisher contact for each book using JOIN...USING clause. Write a query to show the first and last names of customers who have ordered cooking books. Use the WHERE clause to join the tables. Write a query to show the title, cost and ISBN of each book in the books table. If the book has been ordered,...

  • Put all of your SQL code in a file named grades.sql and submit it below. Download...

    Put all of your SQL code in a file named grades.sql and submit it below. Download the starter code, which contains import_grades.sql and the grades.csv file. Using he import_grades, sql file, create your database and table. - 0 eded. 1 T Une Modify the LOAD DATA INFILE to correct the path to load the grades.csv file, and add/remove LOCAL he only modification you may make to the import_grades.sql or the grades.csv files. The data represents grades for assignments in a...

  • 2. Using to Figure 6-11 page 283 of your text book (Modern Database Management, 11th Edition...

    2. Using to Figure 6-11 page 283 of your text book (Modern Database Management, 11th Edition Author: Jeffrey A. Hoffer ; Ramesh Venkataraman ; Heikki Topi VBID: 9781323027226 , write SQL data definition commands for each of the following queries: a) How would you add an attribute, Class, to the Student table? b) How would you remove the Registration table? c) How would you change the FacultyName field from25 characters to 40 characters? Modern Database Management, 11th Edition Author: Jeffrey...

  • Using mySQL, tables at the end... This assignment uses the tables from the vets database. The goa...

    Using mySQL, tables at the end... This assignment uses the tables from the vets database. The goal of the assignment is to get you to think about joins- inner join and outer joins.  If you do a join, where you have the names of two or more tables in the From clause, then you must use the condition join syntax or the column name join. Take care that you do not accidentally do a Cartesian product. If your result set...

  • Topic: Inventory Manangement Part A. Database Creation Your database should have a minimum of 4 tables...

    Topic: Inventory Manangement Part A. Database Creation Your database should have a minimum of 4 tables and include both one-to-many and many-to-many relationships. Be sure to include some numeric and/or date fields. Define all appropriate constraints, using the proper naming conventions (see Structure Notes below). Populate your database with at least 30 records in the main table(s), and whatever is needed in related tables. Submit the following: • a short description of the purpose of the database and what the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT