sql problems with disntinct

1

I have a table in my database with:

  • horarioId
  • horarioParagemId
  • horarioLinhaId
  • horarioHora

I make INNER JOIN of the table rows:

  • linhaId
  • linhaNome

I do INNER JOIN of the table stops:

  • paragemId
  • paragemRua
  • paragemLatitude
  • paragemLongitude

    Example of the schedules table

ScheduleId: 1 scheduleParagemId: 3 scheduleLinhaId: 4 scheduleTime: 22: 00: 00

ScheduleId: 2 scheduleParagemId: 3 scheduleLinhaId: 4 scheduleTime: 21: 00: 00

The goal is only to receive the coordinates where the id of the stops are different. The code I've done works with paragemLatitude or paragemLongitude , but does not work with paragemId

include_once('seguranca.php');
protegePagina();

$sql="SELECT DISTINCT horarioParagemId
      FROM horarios
      INNER JOIN paragens ON paragemId = horarioParagemId
      INNER JOIN linhas ON horarioLinhaId = linhaId
      WHERE horariolinhaId = " . $_GET['filtrapronto'];

$_SESSION['latitudefiltra']= array();
$_SESSION['longitudefiltra']= array();
$result=mysqli_query($con,$sql);

while($dados=mysqli_fetch_array($result)) {

    $_SESSION['latitudefiltra'] [] = $dados['paragemLatitude'];
    $_SESSION['longitudefiltra'] []  = $dados['paragemLongitude'];
}

$obj = new stdClass();
$obj->Latitudes=$_SESSION['latitudefiltra'];
$obj->Longitudes=$_SESSION['longitudefiltra'] ; 
echo json_encode($obj);
    
asked by anonymous 01.06.2016 / 13:43

0 answers