Engineering Questions with Answers - Multiple Choice Questions
MCQs on SQL Queries
Which of these query will display the the table given above ?
a) Select employee from name
b) Select name
c) Select name from employee
d) Select employee
Explanation: The field to be displayed is included in select and the table is included in the from clause.
Here which of the following displays the unique values of the column?
SELECT ________ dept_name FROM instructor;
Explanation: Distinct keyword selects only the entries that are unique.
The ______ clause allows us to select only those rows in the result relation of the ____ clause that satisfy a specified predicate.
a) Where, from
b) From, select
c) Select, from
d) From, where
Explanation: Where selects the rows on a particular condition. From gives the relation which involves the operation.
The query given below will not give an error. Which one of the following has to be replaced to get the desired output?
SELECT ID, name, dept name, salary * 1.1 WHERE instructor;
Explanation: Where selects the rows on a particular condition. From gives the relation which involves the operation. Since Instructor is a relation it has to have from clause.
The ________ clause is used to list the attributes desired in the result of a query.
This Query can be replaced by which one of the following?
SELECT name, course_id FROM instructor, teaches WHERE instructor_ID= teaches_ID;
a) Select name,course_id from teaches,instructor where instructor_id=course_id;
b) Select name, course_id from instructor natural join teaches;
c) Select name, course_id from instructor;
d) Select course_id from instructor join teaches;
Explanation: Join clause joins two tables by matching the common column.
SELECT * FROM employee WHERE salary>10000 AND dept_id=101;
Which of the following fields are displayed as output?
a) Salary, dept_id
d) All the field of employee relation
Explanation: Here * is used to select all the fields of the relation.
This is Employee table.
Which of the following employee_id will be displayed for the given query?
SELECT * FROM employee WHERE employee_id>1009;
a) 1009, 1001, 1018
b) 1009, 1018
Explanation: Greater than symbol does not include the given value unlike >=.
Which of the following statements contains an error?
a) Select * from emp where empid = 10003;
b) Select empid from emp where empid = 10006;
c) Select empid from emp;
d) Select empid where empid = 1009 and lastname = ‘GELLER’;
Explanation: This query do not have from clause which specifies the relation from which the values has to be selected.
In the given query which of the keyword has to be inserted?
INSERT INTO employee _____ (1002,Joey,2000);
Explanation: Value keyword has to be used to insert the values into the table.