31 Lecture

CS403

Midterm & Final Term Short Notes

Inner Join

Inner Join is a type of join operation in SQL that combines matching rows from two tables based on a specified condition. It selects only the rows that have matching values in both tables, and excludes non-matching rows. Inner Join is the most c


Important Mcq's
Midterm & Finalterm Prepration
Past papers included

Download PDF
  1. What is the purpose of an Inner Join in SQL? a. To combine all rows from two tables b. To combine matching rows from two tables c. To combine non-matching rows from two tables d. None of the above Answer: b. To combine matching rows from two tables What is the syntax for an Inner Join in SQL? a. SELECT * FROM table1, table2 WHERE table1.column = table2.column b. SELECT * FROM table1 JOIN table2 ON table1.column = table2.column c. SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column d. Both b and c Answer: d. Both b and c Which of the following types of join can result in NULL values? a. Inner Join b. Left Join c. Right Join d. Full Outer Join Answer: d. Full Outer Join In an Inner Join, what happens if there are duplicate values in the matching columns? a. Only one row is returned for each duplicate value b. All rows with duplicate values are returned c. An error is thrown d. None of the above Answer: b. All rows with duplicate values are returned Which of the following is an example of an Inner Join condition? a. table1.column1 = table2.column2 b. table1.column1 <> table2.column2 c. table1.column1 > table2.column2 d. Both b and c Answer: a. table1.column1 = table2.column2 In an Inner Join, what is the result if there are no matching values in either table? a. All rows from both tables are returned b. No rows are returned c. Only the rows from the first table are returned d. Only the rows from the second table are returned Answer: b. No rows are returned What is the difference between an Inner Join and a Left Join? a. Inner Join returns only matching rows, while Left Join returns all rows from the left table and matching rows from the right table b. Inner Join returns all rows from both tables, while Left Join returns only matching rows c. Inner Join and Left Join are the same thing d. None of the above Answer: a. Inner Join returns only matching rows, while Left Join returns all rows from the left table and matching rows from the right table Which of the following keywords is used in an Inner Join to specify the columns to join on? a. ON b. WHERE c. JOIN d. FROM Answer: a. ON Which of the following operators is used in an Inner Join to combine multiple conditions? a. AND b. OR c. NOT d. XOR Answer: a. AND Which of the following statements is true about the order of tables in an Inner Join? a. The order does not matter b. The first table listed is always the left table c. The second table listed is always the right table d. Both b and c Answer: a. The order does not matter.


Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included

Download PDF
  1. What is an Inner Join in SQL? Answer: An Inner Join is a type of join in SQL that selects only the rows from two tables that have matching values in both tables. What is the syntax for an Inner Join? Answer: The syntax for an Inner Join is "SELECT columns FROM table1 INNER JOIN table2 ON table1.column = table2.column". What is the difference between an Inner Join and a Left Join? Answer: An Inner Join returns only the rows with matching values in both tables, while a Left Join returns all the rows from the left table and matching rows from the right table. Can an Inner Join result in NULL values? Answer: No, an Inner Join does not result in NULL values because it only returns rows with matching values in both tables. What happens if there are duplicate values in the matching columns of an Inner Join? Answer: All rows with duplicate values in the matching columns are returned in the Inner Join. What is the purpose of the ON keyword in an Inner Join? Answer: The ON keyword is used in an Inner Join to specify the columns to join on. Can more than two tables be used in an Inner Join? Answer: Yes, an Inner Join can be performed on more than two tables by joining one table at a time. What is the result if there are no matching values in either table in an Inner Join? Answer: If there are no matching values in either table, then no rows are returned in the Inner Join. What is the difference between an Inner Join and a Full Outer Join? Answer: An Inner Join returns only the rows with matching values in both tables, while a Full Outer Join returns all rows from both tables, including those with NULL values. What is the order of tables in an Inner Join? Answer: The order of tables in an Inner Join does not matter.

In SQL, an Inner Join is used to combine rows from two or more tables where there is a match between the values in certain columns. The Inner Join returns only the rows that have matching values in both tables. The syntax for an Inner Join is as follows: SELECT column(s) FROM table1 INNER JOIN table2 ON table1.column = table2.column; The INNER JOIN keyword is used to combine the tables. The ON keyword is used to specify the columns to join on. For example, suppose you have two tables: Customers and Orders. The Customers table has columns for customer ID, name, and address. The Orders table has columns for order ID, customer ID, and order date. To join the tables on the customer ID column, the following query can be used: SELECT Customers.Name, Orders.OrderDate FROM Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID; This query will return the names of customers who have placed orders and the date of their orders. It is important to note that if there are duplicate values in the matching columns, all rows with duplicate values will be returned in the Inner Join. If there are no matching values in either table, no rows will be returned. In addition, the order of the tables in the Inner Join does not matter. The same results will be returned regardless of the order in which the tables are specified. Inner Joins can be performed on more than two tables by joining one table at a time. It is also possible to use aliases for the table names to make the query easier to read and write. In conclusion, Inner Joins are a powerful tool in SQL for combining data from multiple tables. By understanding how to use Inner Joins, you can write more complex queries that can provide valuable insights into your data.