AND
AND is a logical operator in SQL that combines two or more conditions. It returns true only if all conditions are true.
Example
Output
Explanation
The code illustrates a simple usage of the AND
logic operator in SQL. AND
is used to filter records based on multiple conditions. In this case, it selects customers from the Customers
table that are both in the Country
‘Germany’ and the City
‘Berlin’. The output provides a list of customer details who fulfill both conditions.
Example
Output
Explanation
The above SQL statement selects all columns from the orders
table where the order_date
is greater than or equal to ‘2020-01-01’ AND the total_amount
is greater than 100. Thus, it only returns records that meet both conditions.
Example
Output
Explanation
In this example, the SQL query is used to get data from the Employees
table for those employees who both earn more than 50000
and are younger than 30
years. The AND
logical operator ensures both conditions are satisfied for the rows returned from the query.
Example
Output
Explanation
In the SQL query provided in the example, it selects all data from the ‘employees’ table where the salary is greater than 50000 AND job_id is ‘IT_PROG’. The AND operator combines two Boolean expressions and returns true only if both expressions are true. Therefore, only rows that fulfill both conditions are shown in the output.
Example
Output
Explanation
The above SQL statement selects customers from the “Customers” table that are located in “Berlin”, Germany. The AND operator combines two conditions that must both be true for the row to be included in the result set.