如何从PHP中的三个表查询? [关闭]

Table 1: Listings - listing_id (auto increment) - dealer_id - vehicle_title - location_id - category_id

Table 2: Locations - location_id - location

Table 3: Category - category_id - category

How can I get all listings with the location (from Locations Table) and category (from Category Table).

This is only the query to take information from 3 tables

Select * from Listings,Locations,Category where Listings.location_id = Locations.location_id and Listings.category_id = Category.category_id ; 

The full example of taking information from 2 tables are like that

$Attendance = array();

$query = "SELECT * FROM Temp,Student where Temp.SID = Student.SID ";

$result = mysqli_query($con, $query);

while ($row = mysqli_fetch_assoc($result)) 
{
    $Attendance [$row['SID']] = array ("SID" => $row['SID'] , "CID" =>  $row['CID'] , "SName" => $row['SName'] , "TDate" => $row['TDate'] );   
}

foreach ($Attendance as $i) 
{
    echo "".$i['SID'];
}

This will print to you the SID values .

You have to try the query at first if it work then continue withe code .