Inner join not returning bank values

0

MY BANK

CREATE TABLE EXPERIENCIA(
     exp_pri INT NOT NULL AUTO_INCREMENT,
     nome VARCHAR(150),
     email VARCHAR(50),       
     exp VARCHAR(100),  
     PRIMARY KEY(exp_pri)
);

CREATE TABLE PRANCHA(
    prancha_pri INT NOT NULL AUTO_INCREMENT,    
    tamanho_prancha VARCHAR(8),
    meio_prancha VARCHAR(2),
    litragem_prancha VARCHAR(3),
    PRIMARY KEY (prancha_pri)
);

CREATE TABLE ALTURAPESOESTILO(
    idAltPes INT NOT NULL AUTO_INCREMENT,
    idExp INT,
    idPrancha INT,
    altura VARCHAR(4),
    peso VARCHAR(3),
    estilo VARCHAR(15),
    primary key (idAltPes),
    constraint fk_idExp foreign key (idExp) references EXPERIENCIA (exp_pri),
    constraint fk_idPrancha foreign key (idPrancha) references PRANCHA (prancha_pri)
 );

My SQL:

$query = "SELECT EXP.exp, 
          AEP.altura, 
          AEP.peso, 
          AEP.estilo, 
          PRAN.tamanho_prancha, 
          PRAN.meio_prancha, 
          PRAN.litragem_prancha 
   FROM EXPERIENCIA AS EXP 
   INNER JOIN ALTURAPESOESTILO AS AEP 
   ON (EXP.exp_pri = AEP.idAltPes) 
   INNER JOIN PRANCHA AS PRAN 
   ON (PRAN.prancha_pri = AEP.idAltPes)";

 $resultado = mysqli_query($conexao,$query);

 $retorno = array();

 while($experiencia = mysqli_fetch_assoc($resultado)){
    $retorno[] = $experiencia;
 }

 return $retorno;

}

INDEX.PHP

 include 'banco.php';

    $resultado = array();
    $resultado = BuscaAlgo($conexao);


    foreach($resultado as $valor)
    {
        echo $valor['exp']; print(' '); echo $valor['altura']; print(' '); echo $valor['peso'];  
        echo $valor['estilo']; print(' '); echo $valor['tamanho_prancha']; print(' '); echo $valor['meio_prancha'];
        print(' '); echo $valor['litragem_prancha'];  ?><br> <?php  
    }

I'm putting together three tables and trying to display them. However, both when placing directly in MySql and in my code, nothing is returned. There is no error, but nothing is displayed either.

What can it be?

    
asked by anonymous 14.06.2016 / 16:52

2 answers

0

The inner join only returns if the data is in both tables.

Try to replace your inner join with a left join only to see what information is missing.

    
14.06.2016 / 17:01
1

Dude in your php puts $ result = mysql_query ($ connection, $ query) or die (mysql_error ()); So you're really going to see if the error is in the programming or in the query that you are executing.

    
14.06.2016 / 17:12