Using This code you can join three table for fetching data from mysql.
mysql data and table details :
hostname : localhost
dbusername : dbusername
dbpassword : yourpassword
dbname : dbname
Table Details :
Table 1 : wp_users ( column name : ID , user_login )
Table 2 : user_transactions ( column : user_id , referral_amnt )
Table 3 : user_plans ( column : user_id , amount_paid )
Just copy and paste this code and modify mysql and table details as per your details
<?php
$connect = mysqli_connect("localhost", "dbusername", "yourpassword", "dbname");
$sql = "SELECT * FROM wp_users INNER JOIN user_transactions ON wp_users.ID = user_transactions.user_id
JOIN user_plans ON wp_users.ID = user_plans.user_id";
$result = mysqli_query($connect, $sql);
?>
<!DOCTYPE html>
<html>
<head>
<title>Get Data from Join Three Table</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<br />
<div class="container" style="width:980px;">
<Img src="https://yourdomain.com/wp-content/uploads/2018/12/transparent-logo-1-1.png"width="150px" height="150px"><br>
<h3 align="">Join Three Table</h3><br />
<div class="table-responsive">
<table class="table table-striped">
<tr>
<th>User Name</th>
<th>Total Invested Amount</th>
<th>Referral Amount</th>
</tr>
<?php
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
?>
<tr>
<td><?php echo $row["user_login"];?></td>
<td><?php echo $row["amount_paid"]; ?></td>
<td><?php echo $row["referral_amnt"]; ?></td>
</tr>
<?php
}
}
?>
</table>
</div>
</div>
<br />
</body>
</html>