What is the purpose of using a LIKE clause in a SQL query when filtering data based on the first letter of a column?

When filtering data based on the first letter of a column in a SQL query, the LIKE clause can be used with a wildcard character (%) to match any characters before or after the specified letter. This allows for more flexible filtering options when searching for specific patterns within the data.

// Assuming $conn is the database connection object

$search_letter = 'A'; // Letter to search for
$sql = "SELECT * FROM table_name WHERE column_name LIKE '$search_letter%'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        // Process the retrieved data
    }
} else {
    echo "No results found.";
}