无法从选择查询中的表中获取所有数据

this is my table in phpmyadmin name documents. In html form, dropdown of subject name in not compulsory to select. So it can be blank and get 0 that shown in table. But when I run select query to get all documents list, can't get data of sub_id which value is 0. I want all data from documents table. Plz solve this.

$list=mysqli_query($con,"select documents.*,courses.cour_name,subjects.sub_name from documents join courses on documents.cour_id=courses.cour_id join subjects on documents.sub_id=subjects.sub_id") or die(mysqli_error($con));


doc_id=primary key,
cour_id=index key,
sub_id=index kry


doc_id  cour_id  sub_id  doc_name   
  1       1         0                               
  6       1         2     MB-C250D-AvantGarde-2012.JPG  
  7       1         1     adview.sql    
  8       1         2     crane.txt     
  9       1         0     ui.txt    

result after run select query

Document Id     Document Name                  Course    Subject    
6               MB-C250D-AvantGarde-2012.JPG   B.com     Statistics     
7               adview.sql                     B.com     Accounting     
8               crane.txt                      B.com     Statistics     
查看全部
duandao8607
duandao8607
2017/06/05 06:00
  • php
  • mysql
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复