How can multiple case variations be efficiently handled in a LIKE query in PHP?

When using a LIKE query in PHP, handling multiple case variations efficiently can be achieved by using the SQL UPPER or LOWER function to convert both the column value and the search term to the same case before comparing them. This ensures that the search is case-insensitive and covers all possible variations of the search term.

$searchTerm = "example";
$query = "SELECT * FROM table_name WHERE UPPER(column_name) LIKE UPPER('%$searchTerm%')";
// Execute the query and fetch results