Examveda

Consider a database name "db_name" whose attributes are intern_id (primary key), subject.
Intern_id= {1, 2, 3, 4, 5, 6}
Subject= {sql, oop, sql, oop, c, c++}
If these are one to one relation then what will be the output of the following MySQL statement?
SELECT intern_id
FROM db_name
WHERE subject NOT IN (c, c++);

A. {5, 6}

B. {1, 2, 3}

C. {3, 4}

D. None of the mentioned

Answer: Option D

Solution (By Examveda Team)

This question is about understanding how to use the NOT IN clause in MySQL and how it works with a one-to-one relationship. Let's break it down step by step:
We have a database called "db_name" which stores information about interns and their subjects.
Each intern has a unique intern_id (this acts as the primary key, meaning each intern_id is unique), and they are associated with a single subject.
The "NOT IN" clause in SQL helps us find records that do not match the values listed within the parentheses.
In this case, the query wants to find intern_id values where the subject is NOT "c" or "c++".
Looking at our data:
- intern_id 1 has "sql" as the subject.
- intern_id 2 has "oop" as the subject.
- intern_id 3 has "sql" as the subject.
- intern_id 4 has "oop" as the subject.
- intern_id 5 has "c" as the subject.
- intern_id 6 has "c++" as the subject.
Therefore, the intern_id values that satisfy the condition subject NOT IN ("c", "c++") are {1, 2, 3, 4}.
So, the correct answer is None of the mentioned.

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous