Mysql Join Query

You can use multiple tables in your single SQL query. The act of joining in MySQL refers to smashing two or more tables into a single table.

First you can need database connection in php

Code

<table>
    <thead>
        <tr>
            <th>Make</th>
            <th>Model</th>
            <th>Series</th>
            <th>Seat</th>
            <th>Date</th>
        </tr>
    </thead>
    <tbody>
        <?php
        $sql = "SELECT `cs`.`series_name`,`cs`.`series_id`,`cs`.`status`,`cs`.`created_date`,`cmm`.`model_name`,`cm`.`brand_name`,`cmm`.`seat` from `iosr_car_series` AS `cs` INNER JOIN `iosr_car_master` AS `cm` ON `cs`.`car_id` = `cm`.`car_id` INNER JOIN `iosr_car_model` AS `cmm` ON `cmm`.`model_id` = `cs`.`model_id` WHERE `cs`.`status` != 2"; 
        $result = mysqli_query($con,$sql);
        while($row = mysqli_fetch_assoc($result))
        {
        ?>
      <tr>
        <td><?=$row['brand_name']?></td>
        <td><?=$row['model_name']?></td>
        <td><?=$row['series_name']?></td>
        <td><?=$row['seat']?></td>
        <td><?=$row['created_date']?></td>
      </tr>
      <?php
        }
      ?>
    </tbody>
</table>

Leave a Reply

Your email address will not be published. Required fields are marked *