How can the issue of duplicate or multiple results be resolved when using JOIN queries in PHP?

When using JOIN queries in PHP, the issue of duplicate or multiple results can be resolved by using the DISTINCT keyword in the SELECT statement. This keyword ensures that only unique rows are returned, eliminating any duplicates that may arise from the JOIN operation.

// Example code snippet to resolve duplicate results in a JOIN query
$query = "SELECT DISTINCT column1, column2 FROM table1 JOIN table2 ON table1.id = table2.id";
$result = mysqli_query($connection, $query);

if(mysqli_num_rows($result) > 0){
    while($row = mysqli_fetch_assoc($result)){
        // Process each unique row here
    }
}