Which of the following queries will correctly retrieve the name of Professor from
Professor table with ID 101, 102 or 104?
-
A.
SELECT NAME FROM Professor WHERE id CONTAINS (101, 102, 103);
-
B.
SELECT NAME FROM Professor WHERE id BETWEEN 101 AND 103;
-
C.
SELECT NAME FROM Professor WHERE id IN (101, 102, 104);
-
D.
SELECT NAME FROM Professor WHERE id = (101, 102, 103);
Correct Answer:
C. SELECT NAME FROM Professor WHERE id IN (101, 102, 104);
Explanation:
The correct answer is G because the IN operator in SQL is used to specify multiple values in a WHERE clause, allowing you to filter for a list of specific IDs. Option G correctly uses this syntax to retrieve records where the ID is exactly 101, 102, or 104. Other options are incorrect as CONTAINS is not used for numeric lists in this manner, BETWEEN selects a range rather than specific individual values, and the equals sign can only compare a column to a single value at a time.
Click below to open Discussion & Feedback
0 Issues
Please
login to comment or Report Issues.