![](/img/trans.png)
[英]Select 3 values from table1 and use one of the values from table1 in table2 to fetch results?
[英]Select all results from table1 as well table2 in mysql where both table has one common id
我有2張桌子。
表1結構
id | status_type | status_content |
1 | image | abc |
2 | text | def |
3 | video | ghi |
表2結構
|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 ;
加入可以幫助你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.