Mysql
 sql >> Base de données >  >> RDS >> Mysql

regrouper les valeurs tandem exactes de la colonne 2 ?

Vous pouvez le faire en utilisant PHP :

$query = mysqli_query("SELECT time, lat, `long` FROM Points ORDER BY time");

// output header row
echo str_pad('time', 8) .'|';
echo str_pad('lat', 7) .'|';
echo "long\n";

$prevLat = $prevLong = '';
while ($row = mysqli_fetch_assoc($query)) {
    if ($row['lat'] === $prevLat && $row['long'] === $prevLong) {
        // if this row's lat and long values are the same as the
        // previous row's values, skip this row.
        continue;
    }

    $prevLat  = $row['lat'];
    $prevLong = $row['long'];

    echo str_pad($row['time'], 8) .'|';
    echo str_pad($row['lat'], 7) .'|';
    echo "{$row['long']}\n";
}

Voici un exemple :http://codepad.org/c0SjA058