What are the advantages and disadvantages of using the LIKE operator in a SQL query compared to an exact match comparison in PHP?

When using the LIKE operator in a SQL query, it allows for pattern matching in the search criteria, making it useful for searching for partial matches in strings. However, using the LIKE operator can be slower compared to an exact match comparison in PHP since it has to scan through the entire column to find matches. In contrast, an exact match comparison in PHP can be faster and more precise when searching for exact matches.

// Using an exact match comparison in PHP to search for a specific value in an array
$searchValue = 'John';
$names = ['John', 'Jane', 'Alice', 'Bob'];

foreach ($names as $name) {
    if ($name === $searchValue) {
        echo "Exact match found: $name";
        break;
    }
}