nerdexam
CompTIA

DS0-001 · Question #45

Which of the following statements contains an error?

The correct answer is B. Select EmpId where EmpId=90030 and DeptId=34. Option B contains an error because it is missing the FROM clause - a required component of any SQL SELECT statement that specifies which table to query. The correct syntax would be SELECT EmpId FROM employee WHERE EmpId=90030 AND DeptId=34. Why the distractors are valid SQL: A is

Database Fundamentals

Question

Which of the following statements contains an error?

Options

  • ASelect EmpId from employee where EmpId=90030
  • BSelect EmpId where EmpId=90030 and DeptId=34
  • CSelect* from employee where EmpId=90030
  • DSelect EmpId from employee

How the community answered

(43 responses)
  • A
    2% (1)
  • B
    93% (40)
  • D
    5% (2)

Explanation

Option B contains an error because it is missing the FROM clause - a required component of any SQL SELECT statement that specifies which table to query. The correct syntax would be SELECT EmpId FROM employee WHERE EmpId=90030 AND DeptId=34.

Why the distractors are valid SQL:

  • A is correct syntax: selects a column from a named table with a WHERE filter.
  • C is valid: SELECT* (even without a space) works in most SQL engines and returns all columns from employee.
  • D is valid: a SELECT with no WHERE clause is perfectly legal - it returns all rows.

Memory tip: Think of SQL's required skeleton as S-F-W (Select, From, Where) - From is the only non-optional part after Select. If a query skips FROM but still filters rows, it's broken before it even starts.

Topics

#SQL syntax#SELECT statement#FROM clause#Query errors

Community Discussion

No community discussion yet for this question.

Full DS0-001 Practice