0% found this document useful (0 votes)
15 views15 pages

24ucs172 S5

This document covers algorithm design, focusing on the use of AND and OR operators in SQL for combining multiple conditions in queries. It explains the syntax and provides examples of how to use these operators effectively to filter data from a database. Additionally, it discusses the implications of using multiple operators together and the importance of evaluating conditions correctly.

Uploaded by

jayapratibha.r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views15 pages

24ucs172 S5

This document covers algorithm design, focusing on the use of AND and OR operators in SQL for combining multiple conditions in queries. It explains the syntax and provides examples of how to use these operators effectively to filter data from a database. Additionally, it discusses the implications of using multiple operators together and the importance of evaluating conditions correctly.

Uploaded by

jayapratibha.r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

24UCS172

Computational Thinking

Unit - III –
ALGORITHM DESIGN
UNIT III - ALGORITHM DESIGN

Algorithmic Thinking Algorithm and Flowcharting, Name


binding, Selection, Repetition Filtering,
Pseudocode, Finding max and min, AND, OR operator, Binning
AND&OR operator
• It is possible to combine conditions or actions by
using AND and OR groups to perform multiple conditions or
multiple actions together.
• It is a faster method of building the same type of functionality
that is available in components.
AND
The basic syntax of the SQL AND operator with a WHERE clause is as follows

• 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:

• Condition1, Condition2 are the conditions we want to apply to the query.


Each condition is separated by the OR operator.

• N number of conditions could be combined using the OR operator.


• Here, at least one of the conditions separated by the OR operator must be
TRUE.
OR OPERATOR- EXAMPLE
The following query fetches the ID, NAME and SALARY fields from the
CUSTOMERS table, where the salary is greater than 2000 OR the age is less than
25 years

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

• Where, condition1, condition2, and condition3 represent the conditions that we


want to combine with the AND and OR operators.
• The parentheses group the first two conditions and combine them with the OR
operator.
• The result of that operation is combined with the third condition using the AND
operator.
OR with AND Operator- EXAMPLE
To retrieve all rows from the "CUSTOMERS" table where the age of the customer is
equal to 25 or the salary is less than 4500 and the name is either Komal or Kaushik.
The parentheses control the order of evaluation so that the OR operator is applied first,
followed by the AND operator −

Output

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy