Explore tens of thousands of sets crafted by our community.
SQL Conditional Statements
10
Flashcards
0/10
AND
The AND operator is used to combine multiple conditions in a WHERE clause. Example: SELECT * FROM Users WHERE firstName = 'John' AND lastName = 'Doe';
CASE
The CASE statement is used to create different outputs based on conditions. Example: SELECT CASE WHEN Age < 18 THEN 'Minor' WHEN Age >= 18 THEN 'Adult' END FROM Customers;
IN
The IN operator allows you to specify multiple values in a WHERE clause. Example: SELECT * FROM Customers WHERE Country IN ('Germany', 'France', 'UK');
IS NULL
The IS NULL operator is used to test for empty fields in a column. Example: SELECT * FROM Customers WHERE FirstName IS NULL;
LIKE
The LIKE operator is used in a WHERE clause to search for a specified pattern in a column. Example: SELECT * FROM Customers WHERE Country LIKE 'S%';
NULL
The NULL keyword is used to test for empty values in a column. Example: SELECT * FROM Customers WHERE PostalCode IS NULL;
SELECT ... WHERE
The WHERE clause is used to filter records that fulfill a specified condition. Example: SELECT * FROM Users WHERE age > 30;
OR
The OR operator is used to filter records where at least one of the conditions is true. Example: SELECT * FROM Users WHERE firstName = 'John' OR firstName = 'Jane';
BETWEEN
The BETWEEN operator selects values within a given range. Example: SELECT * FROM Products WHERE price BETWEEN 10 AND 20;
NOT
The NOT operator is used to negate a condition. Example: SELECT * FROM Customers WHERE NOT Country='Germany';
© Hypatia.Tech. 2024 All rights reserved.