MySQL + SQL · Lesson 47

Comparison and Logical Operators in SQL

Comparison Operators

OperatorExample
=marks = 100
<> / !=city != 'Delhi'
> >=age >= 18
< <=fee < 5000

Logical Operators

-- AND: both must be true
SELECT * FROM students WHERE class='10' AND marks>=60;

-- OR: at least one true
SELECT * FROM students WHERE city='Delhi' OR city='Agra';

-- NOT: reverse
SELECT * FROM students WHERE NOT class='10';

Summary

  • Comparison: =, !=, >, <, >=, <=.
  • Logical: AND (both), OR (either), NOT (reverse).
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

WhatsApp