21 AND name LIKE '%John%'.">
The AND operator is used to combine multiple conditions and returns TRUE only if all conditions are TRUE. Syntax: WHERE condition1 AND condition2 AND ..., where condition is the condition that evaluates to TRUE or FALSE. For example, to get customers whose age is greater than 21 and whose name contains "John", the query is: SELECT * FROM customers WHERE age > 21 AND name LIKE '%John%'.
Usage of AND operator in SQL
AND operator is a logic used to combine multiple conditions in SQL operator. It returns TRUE if and only if all specified conditions are TRUE.
Grammar:
WHERE condition1 AND condition2 AND ...
Among them:
condition1
,condition2
, etc. are evaluations A condition that is TRUE or FALSE.Usage example:
Consider the following table structure:
CREATE TABLE customers ( id INT PRIMARY KEY, name VARCHAR(255), age INT );
The following query obtains all those whose age is greater than 21 and whose name contains "John" Customer:
SELECT * FROM customers WHERE age > 21 AND name LIKE '%John%';
In this query:
age > 21
The condition checks if the age of the customer is greater than 21.name LIKE '%John%'
The condition checks whether the customer's name contains the substring "John".Note:
The above is the detailed content of Usage of and in sql. For more information, please follow other related articles on the PHP Chinese website!