选择mysql中表1和表2的所有结果,其中两个表有一个共同的id


Select all results from table1 as well table2 in mysql where both table has one common id

我有两张表

table1 structure

id | status_type | status_content | 
1  | image       | abc            |       
2  | text           | def            |        
3  | video       | ghi            |       

表结构

|file_id | status_id | file_name |
 | 1      |   1       | image.png |
 | 2      |   3       | video.mp4 |

和我想从两个表的所有结果。例如

id | status_type | status_content | file_id | file_name |
1  | image         | abc            |  1      | image.png |
2  | text        | def            |   blank      |   blank        |
3  | video       | ghi            |  3      | video.mp4 |      

您可以使用:

SELECT table1.id,table1.status_type, table1.status_content,
     table2.status_id,table2.file_name,
     FROM table2
     INNER JOIN table2
     ON table1.id=table2.file_id ;