Combining conditions and Boolean operators
The following SQL statement contains the combination condition:
SELECT Column1, SUM (Column2)
From "List-of-tables"
WHERE "Condition1" and "Condition2";
The AND operator can concatenate two or more conditions in the WHERE clause. Both sides of the and condition must be true (true), that is, when two conditions are both satisfied, the rows will be displayed.
Of course, you can also use the OR operator, which can also connect two or more conditions in the WHERE clause. However, the line is displayed only if the condition is satisfied if either side of the OR operator is true. So when you use the OR operator, you can have only one side of the OR operator on either side is true or both sides are true.
Here's an example:
SELECT EmployeeID, FirstName, LastName, title, salary
From Employee_info
WHERE salary >= 50000.00 and title = ' Programmer ';
This SQL statement selects the columns EmployeeID, FirstName, LastName, title, and salary from the Employee_info table salary greater than or equal to 50000.00 and title equals ' Programmer '. The conditions on both sides of the and operator must be true at this point, and the rows will retrieve the results most. If one of the conditions is false, then nothing is displayed.
You can enclose the conditions in parentheses, although they may not necessarily be necessary, but it is a matter of programming custom to enclose them in a clearer context. Like what:
SELECT EmployeeID, FirstName, LastName, title, salary
From Employee_info
WHERE (Salary >= 50000.00) and (title = ' Programmer ');
Here's another example:
SELECT FirstName, LastName, title, salary
From Employee_info
WHERE (title = ' Sales ') or (title = ' Programmer ');
This statement selects the column FirstName, LastName, title, and salary of title equal to ' Sales ' or equal to ' programmer ' from the Employee_info table.