Thursday, April 26, 2018

How To Use INNER JOIN On PHPMYSQLI on 5 Tables:TUTORIAL

Hello...Come back with me at Dkrawn. In this tutorial, I will give you how to use INNER JOIN on PHPMYSQLI on 5 Tables. We know the Inner join itself is used to display data from many tables that have the same relationship.

Inner join is useful if we create comment tables, table orders or other table are connected to each other.

Okay then just follow this tutorial...

-First please see the table data used as below
Table1

Table2

Table3

Table4

Table5 

In the picture above you can know that I am using tabel1, tabel2, tabel3, tabel4 and tabel5 to connect everything using inner join.

After looking at the picture above, let's go directly to the coding show 5 tables using inner join


<table border="1px">
<tr>
                <td>Nilai Tabel 1</td>
                <td>Nilai Tabel 2</td>
                <td>Nilai Tabel 3</td>
                <td>Nilai Tabel 4</td>
               
</tr>
<?php
$koneksi=new mysqli("localhost","root","","inner_join");

$query="select * from tabel5
inner join tabel1 on tabel1.id_tabel1=tabel5.id_tabel1
inner join tabel2 on tabel2.id_tabel2=tabel5.id_tabel2
inner join tabel3 on tabel3.id_tabel3=tabel5.id_tabel3
inner join tabel4 on tabel4.id_tabel4=tabel5.id_tabel4";

$cek=mysqli_query($koneksi,$query);
while($tampil=mysqli_fetch_array($cek)){
?>
<tr>
                <td><?php echo $tampil['nama'];?></td>
                <td><?php echo $tampil['hobi'];?></td>
                <td><?php echo $tampil['kelas'];?></td>
                <td><?php echo $tampil['kelamin'];?></td>
               
</tr>
<?php
}
?>
</table>




-And this is the result



Explanation

$query="select * from tabel5
inner join tabel1 on tabel1.id_tabel1=tabel5.id_tabel1
inner join tabel2 on tabel2.id_tabel2=tabel5.id_tabel2
inner join tabel3 on tabel3.id_tabel3=tabel5.id_tabel3
inner join tabel4 on tabel4.id_tabel4=tabel5.id_tabel4";
-Use of inner join that format as below
select*from tabelpertama innerjoin tabeldua on tabeldua.id_tabeldua=tabelpertama.id_tabelpertama
that's how the use of inner join many tables in php mysqli, to better understand it you should try it directly.

You can look that is video for inner join in 5 table


If you want to download the file above, you can download file below



Download 

Artikel Terkait

How To Use INNER JOIN On PHPMYSQLI on 5 Tables:TUTORIAL
4/ 5
Oleh

Subscribe

Like about this article? you can Subscribe by email