Decode Analytics

View Original

Where AND, OR, NOT

WHERE conditions can be combined with AND, OR, and NOT Operators.

WHERE clause with AND requires that two conditions are true.

WHERE clause with OR requires that one of two conditions is true.

WHERE clause with NOT negates the specified condition(displays if NOT TRUE).

SQL Where AND Syntax:

SELECT  Column1

FROM Table_Name

WHERE condition1 AND condition2;

SQL Where OR Syntax:

SELECT  Column1

FROM Table_Name

WHERE condition1 OR condition2;

SQL Where NOT Syntax:

SELECT  Column1

FROM Table_Name

WHERE NOT condition1;


Example:

Lets use to “Products” table to find all products from the Supplier “TechOne” and with a price under $500.

See this content in the original post



Results:

See this content in the original post

Now lets use the OR operator to find all products with the Supplier Name of “TechOne” or a price under $500.

See this content in the original post

Results:

See this content in the original post

Now we will use the NOT operator to find all products that are not from the Supplier Name '“TechOne”.

See this content in the original post

Results:

See this content in the original post

SQL Tutorials

See this content in the original post