We'll walk through the operators you actually need as a beginner—comparison, logical, range and list, NULL handling, and pattern matching—all in PostgreSQL, with queries I actually ran against a patients table.
Comparison Operators
Comparison operators are the ones you'll use every single day. They return a boolean for every row, and WHERE keeps only the rows where the result is true . The core set is = , <> (or != ), < , > , <= , and >= .
Here's a query for a patients table:
SELECT patient_id , patient_name , bill_amount FROM patients WHERE bill_amount > 10000 ;
Enter fullscreen mode
Exit fullscreen mode
Simple enough. The trouble starts when you combine conditions.
Logical Operators: AND & OR
AND requires both sides to be true. OR requires at least one. NOT negates a condition.…