The LIKE and ILIKE operators are used to query data using pattern mappings.
SELECT first_name, last_name FROM customer WHERE first_name LIKE 'Jen%';
The first_name value returns results starting with Jen. After all, the part that comes after Jen is not important.
SELECT first_name, last_name FROM customer WHERE first_name LIKE '%er%' ORDER BY first_name;
It is a query that returns the first_name values with the letters ‘er’ in them and the corresponding last_name values and sorts them in ascending order according to the first_name values.
SELECT first_name, last_name FROM customer WHERE first_name LIKE'_her%' ORDER BY first_name;
In this query, the first letter of the first_name value is unknown(_), but the query containing the letters ‘her’ from the 2nd letter is returned. The rest of the values after the letters ‘her’ is not important.
SELECT first_name, last_name FROM customer WHERE first_name NOT LIKE 'Jen%' ORDER BY first_name ; SELECT first_name, last_name FROM customer WHERE first_name ILIKE 'BAR%';
The ILIKE function is not case-sensitive.
SELECT first_name, last_name FROM customer WHERE first_name ILIKE 'Bar%';
It returns the same result as the previous query.
In a database, NULL means empty or missing information or not applicable. NULL is not a value, so you cannot compare it to other values such as numbers or strings. Comparing NULL to a value always results in NULL, which means an unknown result.
SELECT first_name, last_name , email FROM customer WHERE email IS NULL;
Returns the first_name and last_name whose email column values are null.
SELECT first_name, last_name, email FROM customer WHERE email IS NOT NULL;
Returns the first_name and last_name whose email column values are not null.