Is it possible to achieve the desired outcome without creating an additional table by utilizing DISTINCT in the SQL query?

The issue is to retrieve unique values from a column in a database table without creating an additional table. One way to solve this is by using the DISTINCT keyword in the SQL query to eliminate duplicate values and only return unique values.

<?php
// Connect to the database
$connection = new mysqli('localhost', 'username', 'password', 'database');

// Check connection
if ($connection->connect_error) {
    die("Connection failed: " . $connection->connect_error);
}

// Query to retrieve unique values from a column
$sql = "SELECT DISTINCT column_name FROM table_name";

$result = $connection->query($sql);

if ($result->num_rows > 0) {
    // Output data of each row
    while($row = $result->fetch_assoc()) {
        echo "Value: " . $row["column_name"] . "<br>";
    }
} else {
    echo "0 results";
}

$connection->close();
?>