In what scenarios would it be necessary to use the LIKE operator in PHP queries instead of the equals operator?

When you need to perform partial matches or pattern matching in your SQL queries, you would use the LIKE operator instead of the equals operator in PHP. This is useful when you want to search for values that contain a certain pattern or substring within a column. Example PHP code snippet:

$search_term = "apple";
$sql = "SELECT * FROM fruits WHERE name LIKE '%$search_term%'";
$result = mysqli_query($conn, $sql);

if(mysqli_num_rows($result) > 0) {
    while($row = mysqli_fetch_assoc($result)) {
        echo $row['name'] . "<br>";
    }
} else {
    echo "No results found.";
}