KnowledgeBoat Logo

Computer Science

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';

SQL Queries

3 Likes

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';

Answered By

2 Likes


Related Questions