CBSE Class 12 Computer Science Question 59 of 78

Simple Queries in SQL — Question 13

Back to all questions
13
Question

Question 13

Which of the following queries contains an error?

  1. Select * from emp where empid = 10003;
  2. Select empid from emp where empid = 10006;
  3. Select empid from emp;
  4. Select empid where empid = 1009 and lastname = 'GUPTA';
Answer

Select empid where empid = 1009 and lastname = 'GUPTA';

Reason — This query lacks the FROM clause. In SQL, the FROM clause is required to specify the table from which we are selecting data. Without it, the query is incomplete and will result in a syntax error. The corrected query is as follows :

Select empid from emp where empid = 1009 and lastname = 'GUPTA';