SESSION NAME: Joins and Unions-2.
QUESTION NAME: Joins of two tables - Hackers.
TABLE DESCRIPTION:
Write a Query to Join the following tables - Use Inner Join
1. We have a table called joins_suppliers with two fields
(supplier_id and supplier_name)
2. We have another table called orders with three fields
(order_id, supplier_id, and order_date)
Write the query to get the following result set
supplier_id name order_year
10000 IBM 2013
10001 Hewlett Packard 2016
1. We have a table called joins_suppliers with two fields
(supplier_id and supplier_name)
2. We have another table called orders with three fields
(order_id, supplier_id, and order_date)
Write the query to get the following result set
supplier_id name order_year
10000 IBM 2013
10001 Hewlett Packard 2016
CODE:
select joins_suppliers.supplier_id, joins_suppliers. supplier_name,
orders.order_year from joins_suppliers Inner Join orders on
joins_suppliers.supplier_id = orders.supplier_id ;

1 Comments
SESSION NAME:Joins and Unions - 2
ReplyDeleteQUESTION NAME: Joins of two tables - Hackers
TABLE DESCRIPTION
Write a Query to Join the following tables
Table 1 = submissions
Table 2 = hackers
Select name field from "submission" table and join the "hackers" table using the common hacker_id column from both the table (submissions table and hackers table)
Hint: Use JOIN
ANSWER:
select hackers.name from submissions Inner Join hackers on
submissions.hacker_id = hackers.hacker_id;