Multiple choice

Which of the following SQL statements accepts user input for the columns to be displayed, table name, and the WHERE condition?

  1. SELECT &1, &2FROM &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';

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Option D correctly uses substitution variables: &1 for first column, '&2' as a literal string (single quotes preserved), EMP as hardcoded table, and &4 for the WHERE condition value. Options A and C incorrectly try to substitute the table name. Option B has malformed quoting with incorrect quote placement that would cause a syntax error.