SQL WHERE AND & OR multiple conditions
The SQL AND & OR operators are used to combine multiple conditions to narrow data in an SQL statement. These two operators are called as the conjunctive operators.
The SQL AND condition and OR condition can be combined to test for multiple conditions in a SELECT, INSERT, UPDATE, or DELETE statement.
The AND Operator - how to create - example
The basic syntax of the AND operator with WHERE is as −
WHERE [condition1] AND [condition2]...AND [conditionN];
Following is an example, which would fetch the ID, Surname and Fees fields from the USERS table, where the Fee is greater than 2525 AND the age is less than 30 years −
WHERE Fee > 2525 AND age <30;
The OR Operator - Example - How to create
The OR operator is used to combine multiple conditions in an SQL statement's WHERE clause.
WHERE [condition1] OR [condition2]...OR [conditionN]
Following is an example, which would fetch the ID, Surname and Fees fields from the USERS table, where the Fee is greater than 2525 OR the age is less than 30 years −
WHERE Fee > 2525 OR age <30;
Syntax The syntax for the AND condition and OR condition together in SQL is:
WHERE condition1 AND condition2 ... OR condition_n;
sql where and or SQL WHERE AND & OR multiple conditions - sql tutorial
2573. SQL HAVING - SQL Tutorial
2597. SQL - Syntax, sql tutorial
SQL - Syntax sql tutorial
3293. SQL update - SQL update select, sql tutorial
SQL update - SQL update select sql tutorial
2589. SQL WHERE - SQL Tutorial
2819. SQL Tutorial
Gives you clear, concise and easy to understand SQL tutorial with practical examples. You will learn how to write SQL query like a Pro.
2572. SQL GROUP BY - SQL Tutorial