Mark for review Which SQL statement accepts user input for the columns to be displayed, the table name, and the WHERE condition?

  1. SELECT &1, "&2"FROM &3 WHERE last_name = '&4';

  2. SELECT &1, '&2' FROM &3 WHERE '&last_name = '&4'';

  3. SELECT &1, &2 FROM &3 WHERE last_name = '&4';

  4. SELECT &1, '&2' FROM EMP WHERE last_name = '&4';


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 uses double quotation marks around &2, which would treat the input value as a string literal instead of a column name.

Option B) SELECT &1, '&2' FROM &3 WHERE '&last_name = '&4''; This option is incorrect because it contains syntax errors. The single quotation mark before "last_name" is misplaced, and there is an extra single quotation mark at the end.

Option C) SELECT &1, &2 FROM &3 WHERE last_name = '&4'; This option is correct because it allows user input for the columns to be displayed, the table name, and the WHERE condition. The input values &1, &2, &3, and &4 will be replaced with the user's input during runtime.

Option D) SELECT &1, '&2' FROM EMP WHERE last_name = '&4'; This option is incorrect because it does not accept user input for the table name. It specifically mentions the "EMP" table instead of using a variable to accept user input.

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.

Find more quizzes: