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."
Related Questions on Sql Miscellaneous
A. Structured Query Language
B. Structured Query List
C. Simple Query Language
D. None of these
Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables?
A. Data Definition Language(DDL)
B. Data Manipulation Language(DML)
C. Both of above
D. None
Which operator performs pattern matching?
A. BETWEEN operator
B. LIKE operator
C. EXISTS operator
D. None of these
What operator tests column for the absence of data?
A. EXISTS operator
B. NOT operator
C. IS NULL operator
D. None of these
Join The Discussion