Skip to main content

Overview

The ENDS_WITH() function determines whether the first argument ends with a specified string in the second argument or not.
  • first_argument: the specified argument, which will be the search reference. It can be a string or a column name.
  • second_argument: the specified argument, which will have the search keywords.
The input type will be STRING, and the return type is BOOL, shown as true or false. Special case:
  • It will return NULL for the NULL record.
  • It will return true (including the NULL record) if the second_argument is not specified.

Examples

#Case 1: ENDS_WITH() function using column

Let’s say we have a table named courses:
The above query will display the following table:
Using the following query, we want to confirm the values of the course_name column that end with “ology” in the table above:
It will return true to all the courses with the name ending with ology. Otherwise, false.

Case 2: ENDS_WITH() function with no specified argument

Here we have the **patients_data **table with a NULL value in the allergies column.
For example, we run the ENDS_WITH function but with no specified second_argument.
We will have the result where the ENDS_WITH will return true to all records (even the null one).