dqeq885710 2016-05-17 17:26
浏览 16

如何从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).

  • 写回答

1条回答 默认 最新

  • donglvmang8638 2016-05-17 17:38
    关注

    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 .

    评论

报告相同问题?

悬赏问题

  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画