SQL Questions and Answers – SQL Operators

This set of SQL Multiple Choice Questions & Answers (MCQs) focuses on “SQL Operators”.

1. In SQL, operators are used with which of the following clause?
a) ORDER BY
b) GROUP BY
c) HAVING
d) WHERE
View Answer

Answer: d
Explanation: In SQL, operators are used with the WHERE clause to perform different logical, arithmetic and comparison operations. Operators are used in SQL statements to executes multiple conditions at once.

2. Which of the following operators are used to perform mathematical operations?
a) Logical
b) Comparison
c) Arithmetic
d) Bit-Wise
View Answer

Answer: c
Explanation: In SQL, the Arithmetic Operators are used to perform the mathematical operations over the operands. The Arithmetic operators include + (Addition), – (Subtraction), * (Multiplication), / (Division) and % (Modulus).

3. What will be the output of the following SQL statement?

advertisement
advertisement
SELECT 100 + 50;
SELECT 100 - 50;
SELECT 100 * 50;
SELECT 100 / 50;
SELECT 100 % 50;

a)

150
50
5000
0
2

b)

150
50
5000
0
0

c)

150
50
5000
2
0
advertisement

d)

150
50
5000
2
2
View Answer
Answer: c
Explanation: The output for the given SQL statement would be –

 150
 50
 5000
 2
 0

+, -, *, /, % operations are for addition, subtraction, multiplication, division and modulus of two numbers respectively.

advertisement

4. The operator <> is used for which of the following comparison operation?
a) Not Equal to
b) Less than Equal to
c) Greater than Equal to
d) Equal to
View Answer

Answer: a
Explanation: The symbol <> is used to check if values of operands are equal or not. If they are not equal then, it returns TRUE.

5. Which of the following operator is used to compare a value to a list of literal values that have been specified?
a) LIKE
b) IN
c) BETWEEN
d) ANY
View Answer

Answer: b
Explanation: The IN operator is used to compare a value to a list of literal values that have been specified. If the value matches any element in the list then it returns true.

6. Which of the following operator is used to negate the meaning of the logical operator with which it is used?
a) NOT
b) OR
c) AND
d) NULL
View Answer

Answer: a
Explanation: The NOT operator is used to negate the meaning of the logical operator with which it is used. If it applied before an expression that return false then the final output will be true and vice-versa.

7. Which of the following operator is used to search a value between a range of values where the maximum and minimum values are specified?
a) ALL
b) LIKE
c) IN
d) BETWEEN
View Answer

Answer: d
Explanation: The BETWEEN operator is used to find a value between a range of values where the maximum and minimum values are specified and also included. If the match is found, the operator returns true.

8. What will be the output of the following statement?

IF a = 10, b = 20 
SELECT (a!=b);

a) True
b) False
View Answer

Answer: a
Explanation: The operator used in the above statement is the not equals to operator. It returns true if the values are not equal and since a is 10 and b is 20 it returns true.

9. Consider the following statement and answer the question that follows:

SELECT column_name
FROM TABLE_NAME
WHERE column_name BETWEEN 10 AND 20;

When using the BETWEEN operator, the output range is –
a) Includes 10 but not 20
b) Includes 20 but not 10
c) Includes both 10 and 20
d) Does not includes 10 and 20
View Answer

Answer: c
Explanation: The Between operator selects and returns values that are within the specified range. When using the BETWEEN operator, the starting and the ending value is always included. The given values could be integers, texts or dates.

10. Which of the following operator is used to search for the presence of a row in a specified table.
a) NOT EXISTS
b) EXISTS
c) IF EXISTS
d) IF NOT EXISTS
View Answer

Answer: b
Explanation: The EXISTS operator is used to search for the presence of a row in a specified table for a given condition. It returns true when value is found.

Sanfoundry Global Education & Learning Series – SQL.

To practice all areas of SQL, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.