SQL Questions and Answers – SQL Self Join

This set of SQL Multiple Choice Questions & Answers (MCQs) focuses on “SQL Self Join”.

1. What is a SELF JOIN?
a) It is an irregular join
b) It is used to join a table to itself
c) It is used to join a table to other tables
d) It cannot be done in SQL
View Answer

Answer: b
Explanation: A SELF JOIN is a regular join, but the table is joined with itself. It is used to join a table to itself as if the table were two tables.

2. Self joins are used to ________
a) Compare values in a column with other values in the same column of the same table
b) Compare values in a column with other values in the same column of the other table
c) Compare values in a column with other values in the other column of the other table
d) Compare values in a column with some given value
View Answer

Answer: a
Explanation: SELF JOIN is used to join or compare a table with itself. SQL self joins are used to compare values of a column with values of same or another column in the same table.

3. SELF JOIN is a keyword in SQL.
a) True
b) False
View Answer

Answer: b
Explanation: There is no keyword as SELF JOIN in SQL. But it is referred when a table joins with itself.
advertisement
advertisement

4. Which of the following is necessary for a SELF JOIN in SQL?
a) Join
b) Alias
c) Order by
d) Group by
View Answer

Answer: b
Explanation: We must use a table alias to distinguish the left table from the right table of the same table in a single query when we perform a SELF JOIN.

5. What is the syntax for self join?
a)

SELECT column_list
FROM table1 SELF JOIN table1
WHERE condition(s);

b)

advertisement
SELECT column_list
FROM table1 JOIN table1
WHERE condition(s);

c)

advertisement
SELECT column_list
FROM table1 T SELF JOIN table1 S
WHERE condition(s);

d)

SELECT column_list
FROM table1 T JOIN table1 S
WHERE condition(s);
View Answer
Answer: d
Explanation: SELF JOIN is not a keyword in SQL. As we refer to the same table twice in a SELF JOIN, we have to use table aliases. Syntax of a self join is:

SELECT column_list
FROM TABLE A (INNER | OUTER) JOIN TABLE B
WHERE condition(s);

6. To construct a SELF JOIN, how many times the same table is selected by a SELECT statement?
a) Only once
b) Twice
c) More than two times
d) Thrice
View Answer

Answer: b
Explanation: To construct a self join, we select the same table twice by using the SELECT statement with an inner join or outer join clause.

Sanfoundry Global Education & Learning Series – SQL.

To practice all areas of SQL, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.