What are the differences between using LIKE and = in MySQL queries when searching for specific data in PHP?

When searching for specific data in MySQL queries in PHP, using LIKE allows for pattern matching while = is an exact match comparison. LIKE is useful when searching for partial matches or patterns within a string, while = is used for exact matches. It's important to use the appropriate comparison operator based on the specific search criteria.

// Using LIKE for pattern matching
$searchTerm = 'example';
$query = "SELECT * FROM table WHERE column LIKE '%$searchTerm%'";
$result = mysqli_query($connection, $query);

// Using = for exact match
$searchTerm = 'example';
$query = "SELECT * FROM table WHERE column = '$searchTerm'";
$result = mysqli_query($connection, $query);