24ucs172 S5
24ucs172 S5
Computational Thinking
Unit - III –
ALGORITHM DESIGN
UNIT III - ALGORITHM DESIGN
• Where, condition1, condition2 are the conditions we want to apply to the query.
• You can combine N number of conditions using the AND operator.
• For an action to be taken by the SQL statement, whether it be a transaction or a
query, all the specified conditions (separated by the AND operator) must be TRUE.
AND- EXAMPLE
A table is created with name Following query inserts values into this
CUSTOMERS in MySQL database table using the INSERT statement
using the CREATE TABLE statement
AND- EXAMPLE
Output:
AND- EXAMPLE
This example would fetch the ID, NAME and SALARY fields from the
CUSTOMERS table, where the salary is greater than 2000 and the age is less
than 25 years −
Output
MULTIPLE AND OPERATORS
• Multiple 'AND' operators could be applied in an SQL query to combine
multiple conditions (or, expressions) together.
• Conditions combined with the 'AND' operators are evaluated from left to
right.
• If any of the condition evaluate to false, the entire compound condition
will be false and the record will not be included in the result set.
Syntax
MULTIPLE AND OPERATORS
Example
Select all records from the CUSTOMERS table where the name of the
customer starts with 'K', the age of the customer is greater than or equal to 22,
and their salary is less than 3742
Output
OR OPERATOR
• The OR operator returns true if at least one its operands evaluates to true,
and false otherwise.
Syntax:
Output
Multiple OR Operators
• Multiple OR operators is used to combine multiple conditions or expressions together.
• While using multiple OR operators, any rows that meet at least one of the conditions
will be included in the result-set.
Example
All records from the CUSTOMERS table is selected where either the name of the
customer ends with 'l', or the salary of the customer is greater than 10560, or their age is
less than 25
Output
OR with AND Operator
AND and OR operators could be used together in to combine multiple conditions in a
WHERE clause to filter rows that meets the specified criteria.
Syntax
Output