Which SQL statement accepts user input for the columns to be displayed, the table name, and the WHERE condition? A. SELECT &1, "&2" FROM &3 WHERE last_name = '&4'; B. SELECT &1, '&2' FROM &3 WHERE '&last_name = '&4''; C. SELECT &1, &2 FROM &3 WHERE last_name = '&4'; D. SELECT &1, '&2' FROM EMP WHERE last_name = '&4';

  1. A

  2. B

  3. C

  4. D


Correct Option: C

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) SELECT &1, "&2" FROM &3 WHERE last_name = '&4'; This option is incorrect because it does not properly handle the user input. The column names, table name, and WHERE condition should be replaced using placeholders (&1, &2, &3, &4), but the WHERE condition is using a string literal ('&4') instead of a placeholder.

Option B) SELECT &1, '&2' FROM &3 WHERE '&last_name = '&4''; This option is incorrect because it also does not properly handle the user input. The WHERE condition is using a string literal ('&last_name = '&4'') instead of a placeholder. Additionally, there is a syntax error with an extra single quote before 'last_name'.

Option C) SELECT &1, &2 FROM &3 WHERE last_name = '&4'; This option is correct because it properly handles the user input. The column names, table name, and WHERE condition are replaced using placeholders (&1, &2, &3, &4). The WHERE condition also uses a placeholder for the user input.

Option D) SELECT &1, '&2' FROM EMP WHERE last_name = '&4'; This option is incorrect because it does not allow the user to input the table name. The table name is hardcoded as 'EMP'.

The correct answer is C. This option is correct because it accepts user input for the columns to be displayed, the table name, and the WHERE condition using placeholders.

Find more quizzes: