Join two MySQL tables with PHP

前端 未结 2 390
滥情空心
滥情空心 2020-12-11 10:36

For example, I have created two pages and two MySQL tables.

Index.php & citys.php

citys

 ID            


        
相关标签:
2条回答
  • 2020-12-11 11:11
    select * from citys 
    left join comments on comments.city = citys.city 
    where citys.id=$id
    
    0 讨论(0)
  • 2020-12-11 11:12

    Use this query

    $sql = "SELECT * FROM citys LEFT JOIN comments ON comments.city=citys.city WHERE citys.id=$id";
    

    Use leftjoin for this type of work

    0 讨论(0)
提交回复
热议问题