WHERE
, HAVING
, and JOIN
clauses. They allow you to create complex conditions by combining multiple expressions. The most commonly used logical operators are AND
, OR
, and NOT
.
AND
, OR
, and NOT
.NOT
, AND
, OR
. Use parentheses to change the order of evaluation.TRUE
if all conditions are true.TRUE
if at least one condition is true.TRUE
if the condition is false.%
and _
).WHERE
, HAVING
, and JOIN
clauses to filter and combine data.AND
operator returns TRUE
if all the conditions separated by AND
are true.
Name | City | Salary |
---|---|---|
Bala | Coimbatore | 60000 |
Raj | Madurai | 70000 |
OR
operator returns TRUE
if at least one of the conditions separated by OR
is true.
Name | City | Salary |
---|---|---|
Anand | Chennai | 50000 |
Raj | Madurai | 70000 |
NOT
operator negates a condition, returning TRUE
if the condition is false.
Name | City | Salary |
---|---|---|
Kavitha | Karaikal | 55000 |
EXISTS
operator checks if a subquery returns any rows. It returns TRUE
if the subquery returns at least one row, otherwise FALSE
.
Name | City |
---|---|
Anand | Chennai |
IN
operator checks if a value matches any value in a list or subquery.
Name | City |
---|---|
Anand | Chennai |
Raj | Madurai |
LIKE
operator is used for pattern matching with wildcards:
%
: Matches zero or more characters._
: Matches exactly one character.Name | City |
---|---|
Kavitha | Karaikal |
Kumar | Trichy |
BETWEEN
operator checks if a value lies within a specified range (inclusive).
Name | Salary |
---|---|
Anand | 50000 |
Bala | 60000 |
Kavitha | 55000 |
Name | City | Salary |
---|---|---|
Bala | Coimbatore | 60000 |
Raj | Madurai | 70000 |
Kavitha | Karaikal | 55000 |
Students
that stores student details.
Table: Students
StudentID | Name | City | State | Percentage |
---|---|---|---|---|
1 | Ram | Chennai | Tamil Nadu | 92 |
2 | Karthik | Coimbatore | Tamil Nadu | 88 |
3 | David | Bangalore | Karnataka | 95 |
4 | Kannan | Karaikal | Puducherry | 91 |
5 | Siva | Madurai | Tamil Nadu | 89 |
Name | City | Percentage |
---|---|---|
Ram | Chennai | 92 |
David | Bangalore | 95 |
AND
, OR
, NOT
) are used to combine or negate conditions in SQL queries.AND
returns TRUE
if all conditions are true, OR
returns TRUE
if at least one condition is true, and NOT
negates a condition.%
and _
).WHERE
, HAVING
, and JOIN
clauses.