I have 2 tables.
table1 structure
id | status_type | status_content |
1 | image | abc |
2 | text | def |
3 | video | ghi |
table2 stucture
|file_id | status_id | file_name |
| 1 | 1 | image.png |
| 2 | 3 | video.mp4 |
and I want all results from both tables. eg
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 |
You can use:
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 ;
A join can help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.