๐ŸŽ…Clauses

Here are SQL examples for each clause for filtering data:

DISTINCT - remove duplicates

SELECT DISTINCT column_name FROM table_name;

LIMIT - constrain number of rows

SELECT * FROM table_name LIMIT 10;

OFFSET - skip number of rows

SELECT * FROM table_name OFFSET 5; 

WHERE - filter on conditions

SELECT * FROM table_name WHERE condition;

Comparison Operators

SELECT * FROM table_name WHERE column_name > 100; 

Logical Operators - AND

SELECT * FROM table_name WHERE column1 = 'value' AND column2 = 'value';

Logical Operators - OR

SELECT * FROM table_name WHERE column1 = 'value' OR column2 = 'value';

BETWEEN - filter between range

SELECT * FROM table_name WHERE column BETWEEN 10 AND 20;

IN - check if value is in list

SELECT * FROM table_name WHERE column IN (value1, value2);

LIKE - pattern matching

SELECT * FROM table_name WHERE column LIKE 'pattern%';

IS NULL - check for NULL values

SELECT * FROM table_name WHERE column IS NULL;

NOT - negate Boolean expression

SELECT * FROM table_name WHERE NOT condition;

Last updated