With WHERE clause, we can SELECT the data conditionally. The AND operator allows you to create an SQL statement based on 2 or more conditions being met for WHERE clause. It can be used in any valid SQL statement - select, insert, update, or delete.

The SQL syntax for the AND operator is:

SELECT [COLUMN NAME] FROM [TABLE NAME]
WHERE [CONDITION 1] AND [CONDITION 2]

In detailed syntax, the SQL syntax can be like this

SELECT [COLUMN NAME] FROM [TABLE NAME]
WHERE [COLUMN 1] = [VALUE 1] AND [COLUMN 2] = [VALUE 2]

The AND condition requires that each condition be must be met for the record to be included in the result set. In this case, [COLUMN 1] has to equal [VALUE 1] and [COLUMN 2] has to equal [VALUE 2].


EXAMPLE :

We would like to return from the data to search person from IT Department that score is more than 2000.

Table GameScores

PlayerNameDepartmentScores
JasonIT3000
IreneIT1500
JaneMarketing1000
DavidMarketing2500
PaulHR2000
JamesHR2000

SQL statement :

SELECT PlayerName FROM GameScores
WHERE Scores > 2000 AND Department = 'IT'

Result:

PlayerName
Jason