Examveda
Examveda

Which of the following query is correct for using comparison operators in SQL?

A. SELECT name, course_name FROM student WHERE age>50 and <80;

B. SELECT name, course_name FROM student WHERE age>50 and age <80;

C. SELECT name, course_name FROM student WHERE age>50 and WHERE age<80;

D. None of these

Answer: Option B

Solution(By Examveda Team)

In SQL, comparison operators are used to compare values in the WHERE clause to filter rows based on specified conditions. The correct usage of these operators is as follows:

Greater than (>): Compares if a value is greater than another.
Less than (<): Compares if a value is less than another.

The correct SQL syntax for using comparison operators to filter rows where the "age" column is greater than 50 and less than 80 is as shown in "Option B."

Let's break down the correct query:
SELECT name, course_name: This part of the query specifies the columns to be retrieved in the result.
FROM student: It specifies the table from which the data is retrieved.
WHERE age > 50 and age < 80: This part specifies the conditions for filtering the rows. It correctly uses the ">" and "<" comparison operators to filter rows where the "age" column is greater than 50 and less than 80.

The correct option, therefore, is "Option B."

This Question Belongs to SQL >> Sql Miscellaneous

Join The Discussion

Related Questions on Sql Miscellaneous